Nice work. You can optimise a little bit by removing redundant code. just check "total == diff" once and perform the "while total == diff" until you get the best j and after you break you can check only once if(a[i].first-a[j].first+1
Kindly verify my time complexity analysis: Here at max: k = nums.length = 3500 ni = nums[ i ].length = 50: let, N = k * ni = total number of elements in whole nums. O(N) -> to make 1 array. O( Nlog(N) ) -> to sort whole array. O(N) = whole array size -> for while/for loop iteration. TC: O(N)+ O( Nlog(N) ) +O(N) => O( Nlog(N) ) Space complexity: O(N) = for whole array. O(k) = map size. SC: O(N + K). Correct me if I'm wrong 🙂🙂.
Nice work. You can optimise a little bit by removing redundant code.
just check "total == diff" once and perform the "while total == diff" until you get the best j and after you break you can check only once if(a[i].first-a[j].first+1
A diff perspective!! Thanks a lot :)
My pleasure!
by taking the hint combining them... i'm able to do it..thx
Well explained, but I think the code can be reduced and improved
Great Video Bhaiya. Just Love Your explanation. 🥰🥰
If possible Could You please bring a video on How to prepare for placements at this stage 🥺🥺
It's been 1 year...
What is going on now?
@@nanda_8 Placed at A Product Based Company with a Decent Salary 😇
@@sanskarkumar7984 that's great 😃😃
So happy for you 😁
@@nanda_8 Thanks a Lot 😇
Great solution. Do you come up with such approach and implementation by your own.
Yes I do!
Good work bro, I think you can remove 1st IF condition(total==diff), it'll give same result
Yes, you are right
@@codeExplainer what is time complexity of the code
Amazing problem and solution!
welcome.
Time - O(n*k*log(n*k)) ???
Space - O(n*k)?
How did you find the time complexity?
We can't really say it's*k as size of k changes
What will be the time complexity of this approach?
Thanks...this was a very good explanation 👍
Glad it was helpful!
Kindly verify my time complexity analysis:
Here at max:
k = nums.length = 3500
ni = nums[ i ].length = 50:
let,
N = k * ni = total number of elements in whole nums.
O(N) -> to make 1 array.
O( Nlog(N) ) -> to sort whole array.
O(N) = whole array size -> for while/for loop iteration.
TC: O(N)+ O( Nlog(N) ) +O(N) => O( Nlog(N) )
Space complexity:
O(N) = for whole array.
O(k) = map size.
SC: O(N + K).
Correct me if I'm wrong 🙂🙂.
Space Complexity to be considered as O(N), k will always be smaller than N
Bro can you please share link of the code?
Where is the code link broooooooo
man you are just amazing
why no more videos now?
was pre occupied with my course , but it is almost completed. Will be back on youtube with more force
@@codeExplainer which course?
What about 9,10
it is smallest range
The background music is irritating
srry that was a old video , that noise does not occur now.
Music 😂