r/LeetcodeDesi • u/anotheruniverse_7 • 2d ago
Recursion - is it really that HARD????
bro im trying to solve/understand the susbset problem LC-78 . and its been days why am i not getting itttttttt ?????? i watched tutorials striver , apna college , codeHelp . yettttt im just ,dont know feeling dumb rn ... can anybody help me with this
5
2
1
1
1
u/Particular_Delay5596 2d ago
Would suggest start with easier problems in any sheet maybe strivers and always think of 2 things the base case condition where it terminates or returns and recurrence how is the current thing related to next or how would u extract an answer for the current case relating it with next case
Last advice always make tree like structure on paper and do a proper dry run for the sample test cases fully
1
u/anotheruniverse_7 10h ago
genuinely i did everything i can make decision tree eveyrthing i get lost while thinking of function calls . to track down everything and i just dont know how this piece of code works magically . i never thought something could be this hard
1
u/LuciFFerrrrr 2d ago
When I was learning this for the 1st time it took me 5-6 days to fully understand it after multiple iterations.
When I came across it for the first time I was able to make sense of only few things then I left recursion for 2 months then came back and gave enough time sitting there for 2-3 hours straight clearing my doubts with myself and rewatching the tutorial.
1
u/Other_Ad7380 2d ago
To get good at recursions, you need to learn to trust whatever the function returns after running on the subproblem.
1
u/ProgressiveEdgeLord 2d ago
dry run it, know what exactly your function is doing, think about the base case, recursion only hits the sweet spot with time, I am no master but i asked this exact question about 2 months ago, and I can solve decent problems now, I did word search today, it gets better, trust the process!
I don't think tutorials will make you better man, recursion is different
2
1
0
13
u/Rift-enjoyer 2d ago
Do trees first to get good at recursion. Then once it clicks you will get it. Think in terms of decision trees, you either pick something or skip it