Understooooooooooooooood? . Instagram(connect if you want to know how a SDE's normal life is): instagram.com/striver_79/ . . If you appreciate the channel's work, you can join the family: bit.ly/joinFamily
Can you please give some articles related to time complexity in maps. I do not understand why time complexity of unordered map is nlogn ...where does this logn come from?
hey striver, i have a doubt with your complexity analysis. In some of the videos you say hashmap takes logN time for operation and in some you say constant time. Can you please tell me if am right about maps that unordered map takes average time of O(1) but ordered map takes logN time.
I do not understand why the TC is O(nlogn) To the best of my knowledge I think it should be O(n) Correct me if I am wrong Any help would be appreciated
Hi bhaiya , let's say the array is (1,-1,1) , so firstly it will be including in hashmap as (1,0) , now when -1 will comes , sum will be 0 , so , maxi = I+1=2 , now again when 1 will come , so it will look into the hashmap , to find 1 , but I don't know , what will it contribute to the ans , I mean what's the use of getting rid of that 1 .
Time Complexity O(N) right? as we traversing the array only one time and checking whether sum is present in Hashmap takes O(1). how time complexity will become O(n Log n), can anyone confirm whether am right or wrong.
How to generate all the subarrays, you have explained in Kadane's algorithm. Bro, it is two nested loops where the outer index goes from 0 to n-1 and the inner index goes from outer index+1 to n-1, you could have said this instead of sending viewers to watch your other video. I have seen this with many RUclipsrs that even for one line they ask you to watch their previous videos.
content bdia hai, effort ke liye salute. But bhai english mt try kro na ek toh fake accent upar se solution itna nhi samajh aata phir english mei try krte ho mix up ho jata hai sab
Understooooooooooooooood?
.
Instagram(connect if you want to know how a SDE's normal life is): instagram.com/striver_79/
.
.
If you appreciate the channel's work, you can join the family: bit.ly/joinFamily
A biiiiiiggggggg yesssssss😋❤️😍
Can you please give some articles related to time complexity in maps. I do not understand why time complexity of unordered map is nlogn ...where does this logn come from?
@@firefangful codeforces.com/blog/entry/50626
I think it should help you.
yoooo
couldnt ask for more.
Can't even say how good this guy is. Awesome explanation brother.
Thanx
@@xdprogrammer9579 Bro why are u saying thanx to that guy. is it your channel ?
🐒
@@ghost10326 🤣🤣🤣🤣🤣🤣🤣🤣
That joyful moment when I understood this approach is invalueable. Thank you so much for this explanation!
what a beautiful explanation striver. Hats off man!!! Hope to work with you as an engineer.
I just love the way you explain every approach nobody else is even near you in terms of explaination
I solve 60% of your sheet by my own but comes here every time to see better approach
How much question solve ?
Can you please forward that cheat sheet
@@sanainaa9972search tuf dsa sheet on Google it's free
@@technoakshay20 bro don't worry it was brute force solution.....he came here to watch tha better and optimal ones😂
today my confusion about storing values in hash table gets cleared.Thank you
Striver: And to understand this in much better way
Clement's girlfriend : Do you know what the scariest thing in the world is😂?
Literally vaeya you are God and true motivation for people who are not from an IIT
Thanks for such a true guidance....
I was stuck in this question but you helped me to solve this. Thanks brother.
thanks.......... great explanation by showing dry run process
Your efforts are really appreciable 🙏
your videos give us a reason to complete the sheet ...Thanku 💖💖
woahhh 👀itne comments mei tumhara comment dikhgya 🤭
@@subhajeetchakraborty1791 himmat hi hai aapki bhi 😂😂
@@mansigoyal4796 arey tops pe hi appear horha tha ye comment 😂
Thank you bhaiya for giving best material of knowledge
The first if condition can be removed by initialising mpp[0] = -1
UNDERSTOOD... !!!
Thanks striver for the video... :)
Amazing explanation. Cant we consider time complexity of unordered_map as constant and hence overall time complexity as O(n)?
The only dry run I listen to very carefully, other ones seem boring and useless :)
if we put mpp[0]=-1 then we don't need to write if(sum==0) maxi=i+1
You really teach very well.
Thank you so much!
hey striver, i have a doubt with your complexity analysis. In some of the videos you say hashmap takes logN time for operation and in some you say constant time. Can you please tell me if am right about maps that unordered map takes average time of O(1) but ordered map takes logN time.
Yes u r right. Unordered worst is o(n)
How to identify which is ordered map or unordered map??
@@agyaani8060 if u declare it as map only then it's ordered...for making it unordered we mention unordered_map
@@priyankarai7005 in java?
very nice explaination.
TYSM striver bhaiya
The code for this problem is same code we did for longest subbarrau with sum k,both are same?
Will never forgot this question. Was asked in grab interview couldn't think of hashmap approach
thans bro understood , and coded the logic in first go without seeing the code
I say so many vedioes but the problem was not clear at the time of leaving the problem yt god recomended this. Understooodddd
How can we print that subarray ?
crisp & Clear. Thanks @striver
after you read the code once you realise how easy it is... i knew we had to use kadane's algorithm, im glad atleast i realised that. thanksss!!
I do not understand why the TC is O(nlogn)
To the best of my knowledge I think it should be O(n)
Correct me if I am wrong
Any help would be appreciated
It's O(n) not nlog n
Operation to find a key in a hashmap takes logN time.
Bro channel ki FAANG playlist ko rename kro , aur starting mein #123 numbering kr do , it will be easier to understand where to start
playlist pe jaao sb 1 to .. tak hi h .. also sde sheet pe numbered h
such a wonderful logic and explanation
This guy make DSA way too easy😎
Beautifully explained , mazza agaya
Hi bhaiya , let's say the array is (1,-1,1) , so firstly it will be including in hashmap as (1,0) , now when -1 will comes , sum will be 0 , so , maxi = I+1=2 , now again when 1 will come , so it will look into the hashmap , to find 1 , but I don't know , what will it contribute to the ans , I mean what's the use of getting rid of that 1 .
But the max length will not change I think..
Superb explanation..! Awesome
just one doubt,time complexity should be n beacause it takes constant time to acess aw well as insertion the hashmap
please reply
Even Iam thinking the same
Why have you taken log n complexity for unordered map?
why is this problem given under hard section in your sheet?
Bhaiya can we apply sliding window approach here?
complexity would be O(n log(n) ) so yeah it's applicable
Thanks this is the best way anyone can explain this solution to me xD
why subbbarrray seem little bit different in your tone btw love this
Thanks Striver Bhaiyya..It helped a lot
Good Explanation but That Sub-Array Accent 😂
@striver bhaiya, for C++ sol, u have used unordered map but for time complexity analysis, u used ordered_map complexity. Right?
yes same question
Yes I have also ask same q
Really good explanation. why does it not seem to be an easy problem? It seems to be of at least medium level to me
Lets see who is coding now!
Thank you so much Raj bhaiya!
Glad I found your channel!
trversing will take O(N) right in java can any plss explain me
how the time complexity is O(nlogn) raj. Hashmap insertion and retrieval can be done in O(1) na ?
Depends... unordered hashmap takes N in worst case due to collisions, we can say it as n or n log n in interview and then explain !
@@takeUforward okay. Thank you. 😊
Using hashmap T.C will be O(n) from O(n^2)??
WONDERFUL EXPLANATION !!!!!
understood striver , thank you
@take U forward Amortized time complexity of insertion or retrieval in HashMap is O(1) then how come time complexity is O(NlogN)
In c++ the average case for map is logn, for unordered map its o(1) but the worst goes to o(n) in rare occasions.
@@takeUforward okay thanks bro..got it...u r doing great work...keep it up...
Nicely explained #striver sir, keep posting such videos, waiting for further video explainations from your SDE sheet.
Your SDE sheet is the best!!
crystal clear explaination
Awesome explaination bro
jitna bhi thanks bole kam hai bhaiya❤❤❤
instead of first if statement in the for loop we can directly put(0,-1) in the hash map after creating it. This works.
Time Complexity O(N) right? as we traversing the array only one time and checking whether sum is present in Hashmap takes O(1). how time complexity will become O(n Log n), can anyone confirm whether am right or wrong.
Great clear explanation !
love the accent and explanation both😉😉😉😉
If we use unordered_map in C++ then TC will be O(n) only/
that's what we use, unordered_map or HashMap (java)
but striver have TC of logn
@@nasim3987 no, its n*logn
.find fn will hav logn only even if its unordered mP
bhau lovely explained thanks
but bro esse logic mujhe nahi aate jab mei krta hu
crystal clear explanation
i like how he says 'subaaarrrrrrrrraayy'
Thank you so much bro!
can we solve it with sliding window??
great explanation bro, thanks a lot
Thanks a lot for this much effort bhaiya 😀
superb explanation
How to generate all the subarrays, you have explained in Kadane's algorithm. Bro, it is two nested loops where the outer index goes from 0 to n-1 and the inner index goes from outer index+1 to n-1, you could have said this instead of sending viewers to watch your other video.
I have seen this with many RUclipsrs that even for one line they ask you to watch their previous videos.
Thank you bro. Understood.
Great explaination
Informative 👍
great Explanation...!!!
Bhai it is also useful for cp.
who marked this question as easy in GFG...it's leetcode medium level i think!
Hare Krishna!
Thanxx bro for such a nice explanation
Bhaiya esa kyo horra h m part 4 pr aa gayi to merai s brute froce hi bnti h optimized nahi kya kru 😣😖😖
Make a python beginners series
awesome explanation
can't we do this using Dp
Same problem how to solve this using segment tree pls if possible send some link, relevant problem which can be solved with segment tree
hash map has average o(1) time complexity and worst case O(n).Why are you using O(logn)
content bdia hai, effort ke liye salute. But bhai english mt try kro na ek toh fake accent upar se solution itna nhi samajh aata phir english mei try krte ho mix up ho jata hai sab
Thanks Striver bhai .............
brute force ...
int maxLen=0;
for(int i = 0 ; i
Superrr Explanation!!!!
what if i have to return the array with those elements
Store the 1st and last index of the longest subarray into variables..and print i=1st to last
this guy sounds like the tech guy involved in scams lol
ya
Thankyou sir Understood🙏🙇♂❤
And this marked as easy
Crystal Clear ASF
What's the name of this algorithm?
Simply excellent
Can someone pls share the brute force solution!!!
I got the similar kind of question in the interview of sprinklr, in round1, but they asked me to find sum == k
bro did you get selected?
understood bhaiya
Awesome bro!!
Understood Sir!