Hi, there! Thank you for the explanation, but in the first example nums = [1, 0, 0] and queries = [[0,2]] it's not clear for me why we're not modifying the number zero. Could you please explain this? Thanks a lot!
@dThapa9663 күн бұрын
Because at the end, we are looking for our array to be all 0's example - [0,0,0,0] at the end. If you decrement more than 0, you'll get a negative number. So subtracting further after seeing a 0 will ruin the array.
@RoadToFAANG19923 күн бұрын
What @dThapa966 said is correct. We want to make all the elements equal 0. For each query, we only need to choose a subset of elements in the range. This means that we can choose not to decrement any elements which are already 0
@DEEPAKDESHMUKH-q2r9 күн бұрын
your explanation is best and easy to understand that i can find , please do it regularly for every contest(only 2nd and 3rd question🙂)
@RoadToFAANG19929 күн бұрын
Thank you! I’m glad it was helpful and will continue to do as many contests as I can
@moonshine88489 күн бұрын
isnt finding the length of the keys a 0(N) operation, so the total time complexity is O(Q*N)? shouldnt u have a counter to does it instead??
@CongNguyen-og3iz10 күн бұрын
Thanks for the solution! It's really clever
@RoadToFAANG199210 күн бұрын
Thank you! I’m glad it was helpful
@ayoni0216 күн бұрын
It was helpful, Thanks
@RoadToFAANG199216 күн бұрын
No problem! I’m glad it was helpful
@mukulkhanna2617 күн бұрын
Thanks a lot for resources and guidance too bruh
@RoadToFAANG199217 күн бұрын
Absolutely! I’m glad you found it helpful
@ShariqueAkhtar22 күн бұрын
so underrated channel.. the explanation is top notch
@RoadToFAANG199222 күн бұрын
Thank you! I really appreciate it
@DEEPAKDESHMUKH-q2r22 күн бұрын
nice explanation
@RoadToFAANG199222 күн бұрын
Thanks! I’m glad it was helpful!
@myko_chxn27 күн бұрын
amazing solution. which category would this problem fall under? math?
@RoadToFAANG199227 күн бұрын
Thank you! Yea I think this would be considered to be a math/geometry problem.
@sierr1302Ай бұрын
Great stuff. Failed an interview recently I wasn’t ready. Back to the books.
@RoadToFAANG1992Ай бұрын
It happens to all of us. The only way we can truly fail is if we stop trying so take a small break and get back to the grind
@robindey4273Ай бұрын
A great and smooth explanation❤ Thanks
@RoadToFAANG1992Ай бұрын
Glad it helped!
@rsKayiiraАй бұрын
Quick question how accurate are the scores attached to contest questions when gauging difficulty? they range from 1-11 but usually questions asked in contests have a rating of between 3-7
@RoadToFAANG1992Ай бұрын
I think they are a pretty good indicator of the general difficulty but they are not exact. For example, if I see an 8 I’m pretty sure it’s going to be a very hard problem. On the other hand a 5 I sometimes find pretty easy or quite hard. It’s a good general guide but not exact.
@rsKayiiraАй бұрын
@@RoadToFAANG1992 I see got it. Thank you.
@rsKayiiraАй бұрын
@@RoadToFAANG1992 okay thank you so much. Btw how accurate is zerotrac? If I did say all 1200-1300, 1300-1400 level problems and understood them, could I expect to be able to do qn 1 consistently in contests. My target right now is to be able to do Qn 1 and 2 consistently. Seems for Qn 1 you need to be good with 1100-1400 level problems and for Qn 2 you need to be good with 1400-1800 level problems
@RoadToFAANG1992Ай бұрын
I would say it depends on the contest. Recently the contests have become extremely hard to try and stop people from cheating using ChatGPT. If you can get to 1800 I would say for most contests you would be able to solve 3 questions but maybe only 2 in more recent contests. Q1 is usually very easy so as long as you are confident in your DSA I think Q1 should be fine. However in some recent contests Q1 have been medium even though they are a bit on the easier side
@rsKayiiraАй бұрын
@@RoadToFAANG1992 I see!! Damn they are making them more difficult. Thanks for the feedback. I’m trying to do all weekly between 1200-1400 since my rating is at 1250 despite doing 900 LC. Basically starting over. My target is to hit 1700 or at most 1800 by next year
@aadityatripathi8363Ай бұрын
great video. Thanks for introducing zerotrac to me
@RoadToFAANG1992Ай бұрын
Of course! It’s a great resource hopefully it’s helpful for you
@rsKayiiraАй бұрын
Congratulations, great video and honest video. Thank you
@RoadToFAANG1992Ай бұрын
Thank you! I’m glad this video was helpful for you
@riyanshbiswasАй бұрын
BEST explanation that i found for this question. Thank you! It was a nightmare just to understand it.
@RoadToFAANG1992Ай бұрын
Perfect! I’m glad I can help
@night5722Ай бұрын
Thank you for content, I always use it to reflect & learn post contest.
@RoadToFAANG1992Ай бұрын
Glad the content is helpful for you! I will keep creating it but also let me know what types of content would help you more!
@sierr13022 ай бұрын
Wonderful video. Investing in at 81 subs. You deserve more. Keep goin brotha!
@RoadToFAANG19922 ай бұрын
Thanks! Glad you’re liking the content!
@yashmundada24832 ай бұрын
Nicely done
@RoadToFAANG19922 ай бұрын
Thanks!
@shan_singh2 ай бұрын
finally an explanation that i can easily understand, well put together, precise. Thank you
@RoadToFAANG19922 ай бұрын
Glad it was helpful!
@amarkoni94813 ай бұрын
this was pretty good mate, cheers
@RoadToFAANG19923 ай бұрын
Glad you enjoyed it!
@johnlocke46953 ай бұрын
Great videos! Your explanation is short and concise. Please don't stop making such amazing videos.
@RoadToFAANG19923 ай бұрын
Glad you like them!
@johnlocke46953 ай бұрын
I wasted an hour because I couldn't understand the question in the contest.
@RoadToFAANG19923 ай бұрын
The description was definitely unclear. Leetcode really needs to to better with these contests
@jordanshand73933 ай бұрын
Great job breaking the problem down and coherently explaining your logic step by step.
@RoadToFAANG19923 ай бұрын
Glad it was helpful!
@shivansh-gup3 ай бұрын
Thanks this solution is understandable. I will need more practice to come up with it in contest itself.
@RoadToFAANG19923 ай бұрын
Me too. I was not able to get it in the contest. We just need to keep grinding and we will get there
@monstrnub86163 ай бұрын
Hey how did you manage to pass the last testcase, I am getting TLE with your same code, i got it from your profile on leetcode so its same. It fails on last test case.
@RoadToFAANG19923 ай бұрын
That’s weird. Let me try to run it again. Maybe they tightened the constraints since after the contest
@monstrnub86163 ай бұрын
@@RoadToFAANG1992 let me know did it pass for you or not
@RoadToFAANG19923 ай бұрын
The original solution is getting a TLE but if on line 18 you change it to `for count, x in pairs[:100]:` it will work. In this case we only go through the first 100 possible x values
@monstrnub86163 ай бұрын
It would be better if you could give a link to your code, try to have your leetcode screen at 150% or more as its hard to read from small characters. Everything else is fine
@RoadToFAANG19923 ай бұрын
That’s a great idea. Will definitely do that in future videos
@gavinebenezer16704 ай бұрын
Good way of explaining
@RoadToFAANG19924 ай бұрын
Thanks! I’m glad it was helpful
@sparrow2434 ай бұрын
I sub y thanks for such a great content
@RoadToFAANG19924 ай бұрын
Thanks you for subscribing! I’m glad you are enjoying the content
@abdifatahmoh4 ай бұрын
This is a good explanation. Thank you for that but instead of using an indices array, you could use a dictionary for constant look-up. something like this: occurrences = {} for i in range(len(nums)): if nums[i] == x: if x in occurrences: occurrences[x].append(i) else: occurrences[x] = [i]
@RoadToFAANG19924 ай бұрын
Thanks for the comment! Yes we could definitely do it this way with a hashmap as well. Using the array should still be a constant look up however, since we are just getting a specific index in the array and not traversing through the whole thing each time.
@jubiliudu5 ай бұрын
Great! Best solution, thanks!!
@RoadToFAANG19925 ай бұрын
Glad it was helpful!
@rajan-u6b6 ай бұрын
thanks man, nice
@RoadToFAANG19926 ай бұрын
No problem!
@IOSALive7 ай бұрын
Road To FAANG, You're amazing! Let's be friends and hang out!