Hello, a simple way to solve this is by using the 1st approach sir mentioned in the video: class Solution { public: int missingNumber(vector& nums) { int n=nums.size(); int sum=n*(n+1)/2; int s=0; for(int i=0;i
We can also use cyclic sort in this problem, which is both time and memory efficient. Code: class Solution { public: int missingNumber(vector& nums) { int n = nums.size(); int i = 0; for(;i
when we do l m){//we are on res idx or res is on left r = m; } else{//everything is fine till this idx,check for next l = m+1; } } return l or r doesn't matter;
@codestorywithmik. I have a doubt if we store 0 in res instead of n this code is not working why so is any other way to make changes in code if we want to store 0 in res instead of n one more how we will come to know in these types of questions whether we have to store n in result or 0 in res plz reply bro
can we solve this question by using hash sets, since one main property of hash sets is we cannot add repeated numbers and that way the time complexity will also be O(1)
can any one tell me when we use sort(v.begin(, v.end()) in c++ which type of sort it is? we take worst case complexity as nlogn then what is best case and average case ?
Hello, a simple way to solve this is by using the 1st approach sir mentioned in the video: class Solution {
public:
int missingNumber(vector& nums) {
int n=nums.size();
int sum=n*(n+1)/2;
int s=0;
for(int i=0;i
We can also use cyclic sort in this problem, which is both time and memory efficient.
Code:
class Solution {
public:
int missingNumber(vector& nums) {
int n = nums.size();
int i = 0;
for(;i
Well explained as always
Amazingly explained!
good explanation sir.one correction in java code in 3rd approach int result =n;
solved on my own using 2 approaches
came here to learn something new
Thanks
POTD DONE[20.2.24] ✅✅
when we do l m){//we are on res idx or res is on left
r = m;
}
else{//everything is fine till this idx,check for next
l = m+1;
}
}
return l or r doesn't matter;
Thank mik. if you get time, can you please post weekly contest Qn-4 of this week
Thanks for this!
Bhaiya bit manipulation pe bhi playlist bana do pls
Thanks a lot bhaiya ❤❤
Great video 👌🏻
Please make the pending video on delete implementation in trie.
Noted on this 👍🏻
@codestorywithmik. I have a doubt if we store 0 in res instead of n this code is not working why so is any other way to make changes in code if we want to store 0 in res instead of n
one more how we will come to know in these types of questions whether we have to store n in result or 0 in res
plz reply bro
Hello bhaiya . Can u please make a video on q no.4 of leetcode biweekly 124...which happened on last saturday. Thanks.
amazing !
Niceee. Thanks
can we solve this question by using hash sets, since one main property of hash sets is we cannot add repeated numbers and that way the time complexity will also be O(1)
Yes but space will become O(n)
can any one tell me when we use sort(v.begin(, v.end()) in c++ which type of sort it is? we take worst case complexity as nlogn then what is best case and average case ?
sir please leetcode ques number 621 (Task Scheduler) bata dejiye
❤❤
bhaiya jo 3rd approach me code likha h vha O(nlogn) time complexity nhi aaeggi
Haa