Great Explanation, Always crushed my doubts 😂, Keeping Neetcoding❤
@Gojo-hl7iu2 ай бұрын
Thank you sooo much for your daily uploads
@sriramgugulothu41952 ай бұрын
Very clear explanation.
@phillipwils2 ай бұрын
Excellent presentation as always. Thanks for showing the recursive and iterative solutions. By the way, I was reviewing the code by hand and I noticed that every number is visited 10 times instead of once for the recursive implementation. The time complexity is still linear. The recursive solution time complexity is Time: O(10*n) => 10 * O(n) => O(n) Verify with paper and code with n = 275 def __init__(self): self.count = 0 def dfs(start): self.count += 1 ... print(self.count) # 2759) return result n=275 dfs(1) res = [1, dfs(10) res = [1,10, dfs(100) res = [1,10,100, for [0..9] dfs(100), dfs(101), ... dfs(109) dfs(1000), dfs(1010),...dfs(1090) dfs(101) res = [1,10,100,101,
@floman31582 ай бұрын
Something about recursive functions is annoying me so much that I always try to avoid those solutions.
@leeroymlg4692Ай бұрын
you should learn it. some problems are overly complicated without recursion. like binary tree
@souriksharma2 ай бұрын
I tried doing it with string for simplicity but.........yeah it exceeded the time limit and when I ran in in my IDE it took wooping 32.3 sec to sort 14959 in lexicographical order.
@satyamjha682 ай бұрын
Solved it using Trie !
@RIPNANI2 ай бұрын
Bro look at the follow ups
@satyamjha682 ай бұрын
@@RIPNANI Ya I know that ! Its just that this approach came to my mind first!
@deepakjain44812 ай бұрын
@@satyamjha68 how to solve it using that
@RIPNANI2 ай бұрын
@@satyamjha68 k
@MP-ny3ep2 ай бұрын
Great explanation as always. Thank you !
@ngoquangtrung2342 ай бұрын
Great explaination.
@_sf_editz18702 ай бұрын
Just like everyday nice and smooth
@ap2s20002 ай бұрын
I love you neet
@VanjeAv2 ай бұрын
Amazing thanks
@GullemClydeCyrilS2 ай бұрын
awesome!
@jamescraft53002 ай бұрын
hello!
@maanas_sehgal2 ай бұрын
Hey I need suggestions! So I am 1526 rated on Leetcode rn and I was planning to start with neetcode sheet. Should I pursue 150 or 580 first? I mean 580 has all the types of problems but will take long. 150 has important ones😅
@neks20812 ай бұрын
dont do 580, solve 150 and then do questions by topics you suck at
@maanas_sehgal2 ай бұрын
@@neks2081 k
@abdalmlck44982 ай бұрын
but how SC is 1 ? you did save it in the res ?
@albin_joby2 ай бұрын
res = [] def check(num): for i in range(0,10): val = num*10+i if val
@Sarojkumar-yh9uy2 ай бұрын
res = [] def check(num): for i in range(0,10): val = num*10+i if val
@deepakjain44812 ай бұрын
i tried it but i think it does not work
@tauicsicsics2 ай бұрын
Can you please do Basic Calculator 1 and 2? TBH all Top Leetcode 150 interview questions would be great, thanks.
@mcbotface2 ай бұрын
Why do you make easy problems complicated? lst = [i for i in range(1,n+1)] return sorted(lst, key=lambda x:str(x)) This solution had 59ms runtime and runtime was better than 96.89% solutions.
@NeetCodeIO2 ай бұрын
Try to compare the time complexity of your solution with mine. Maybe you will figure it out. Maybe not.
@mcbotface2 ай бұрын
@@NeetCodeIO Yeah my solution has TC of O(NlogN) while yours has O(N)
@gmh142 ай бұрын
@@mcbotface ????? the question states TC should be O(n)
@mcbotface2 ай бұрын
@@NeetCodeIO You were right. I get "memory limit exceeded" for today's POTD using yesterday's approach return sorted([i for i in range(1,n+1)], key=lambda x:str(x))[k-1]
@mcbotface2 ай бұрын
@@gmh14 No I guess. That's why my solution was accepted. Although the TC was O(NlogN)
@100nitishyadav82 ай бұрын
why people using dfs in this, i just made a list from 1 to n the custom sorted it using comparator by converting into string is that bad solution ?
@homelander.lover91142 ай бұрын
Constraint I O(n), sorting is n logn
@33galactus2 ай бұрын
@@homelander.lover9114 Exactly, your solution is simple but O(nlogn) time and O(n) space complexity make it sub-optimal.
@mohammedsuhail.s1922 ай бұрын
i think it was not a bad solution but the contraint should play in the problem because they want to be space complexity should be O(1) so we dont create any extra space for that it is my intuation
@sriramgugulothu41952 ай бұрын
There is a constraint of running algorithm in O(n). Sorting takes more than O(n).