Recursion is a problem-solving technique in which the solution is dependent on solutions to smaller instances of the same problem. Computing factorials is a classic example of recursive programming.
Every recursive program follows the same basic sequence of steps:
Set up the algorithm. Recursive programs frequently require a seed value, to begin with. This is accomplished by either using a parameter passed to the function or by providing a non-recursive gateway function that sets up the seed values for the recursive calculation.
Check to see if the current value(s) being processed correspond to the base case. If so, process the value and return it.
Rephrase the solution in terms of a smaller or simpler sub-problem or sub-problems.
Apply the algorithm to the sub-problem.
In order to formulate an answer, combine the results.
Return the results.
Every recursive program follows the same basic sequence of steps:
Set up the algorithm. Recursive programs frequently require a seed value, to begin with. This is accomplished by either using a parameter passed to the function or by providing a non-recursive gateway function that sets up the seed values for the recursive calculation.
Check to see if the current value(s) being processed correspond to the base case. If so, process the value and return it.
Rephrase the solution in terms of a smaller or simpler sub-problem or sub-problems.
Apply the algorithm to the sub-problem.
In order to formulate an answer, combine the results.
Return the results.
Leetcode patterns you should definitely checkout to Learn DSA(Java) from scratch
1οΈβ£ Arrays: Data structures, such as arrays, store elements in contiguous memory locations. They are versatile and useful for a wide variety of purposes.
LeetCode Problems:
β’ Search in Rotated Sorted Array (Problem #33)
β’ Product of Array Except Self (Problem #238)
β’ Find the Missing Number (Problem #268)
2οΈβ£Two Pointers: In Two Pointers, two pointers are maintained in the collection and can be manipulated to solve a problem efficiently.
LeetCode problems:
β’ Trapping Rain Water (Problem #42)
β’ Longest Substring Without Repeating Characters (Problem #3)
β’ Squares of a Sorted Array (Problem #977)
3οΈβ£In-place Linked List Traversal: As an explanation, in-place traversal is a technique for modifying linked list nodes without using extra space.
LeetCode Problems:
β’ Remove Nth Node From End of List (Problem #19)
β’ Reorder List (Problem #143)
4οΈβ£Fast & Slow Pointers: This pattern uses two pointers to traverse a sequence at different speeds (fast and slow), often used to detect cycles or find a specific position in the sequence.
LeetCode Problems:
β’ Happy Number (Problem #202)
β’ Subarray Sum Equals K (Problem #560)
β’ Intersection of Two Linked Lists (Problem #160)
5οΈβ£Merge Intervals: This pattern involves merging overlapping intervals in a collection, often used in problems dealing with intervals or ranges.
LeetCode problems:
β’ Non-overlapping Intervals (Problem #435)
β’ Minimum Number of Arrows to Burst Balloons (Problem #452)
Join for more: https://t.me/crackingthecodinginterview
DSA Interview Preparation Resources: https://topmate.io/coding/886874
ENJOY LEARNING ππ
1οΈβ£ Arrays: Data structures, such as arrays, store elements in contiguous memory locations. They are versatile and useful for a wide variety of purposes.
LeetCode Problems:
β’ Search in Rotated Sorted Array (Problem #33)
β’ Product of Array Except Self (Problem #238)
β’ Find the Missing Number (Problem #268)
2οΈβ£Two Pointers: In Two Pointers, two pointers are maintained in the collection and can be manipulated to solve a problem efficiently.
LeetCode problems:
β’ Trapping Rain Water (Problem #42)
β’ Longest Substring Without Repeating Characters (Problem #3)
β’ Squares of a Sorted Array (Problem #977)
3οΈβ£In-place Linked List Traversal: As an explanation, in-place traversal is a technique for modifying linked list nodes without using extra space.
LeetCode Problems:
β’ Remove Nth Node From End of List (Problem #19)
β’ Reorder List (Problem #143)
4οΈβ£Fast & Slow Pointers: This pattern uses two pointers to traverse a sequence at different speeds (fast and slow), often used to detect cycles or find a specific position in the sequence.
LeetCode Problems:
β’ Happy Number (Problem #202)
β’ Subarray Sum Equals K (Problem #560)
β’ Intersection of Two Linked Lists (Problem #160)
5οΈβ£Merge Intervals: This pattern involves merging overlapping intervals in a collection, often used in problems dealing with intervals or ranges.
LeetCode problems:
β’ Non-overlapping Intervals (Problem #435)
β’ Minimum Number of Arrows to Burst Balloons (Problem #452)
Join for more: https://t.me/crackingthecodinginterview
DSA Interview Preparation Resources: https://topmate.io/coding/886874
ENJOY LEARNING ππ
π7
Prepare for GATE: The Right Time is NOW!
GeeksforGeeks brings you everything you need to crack GATE 2026 β 900+ live hours, 300+ recorded sessions, and expert mentorship to keep you on track.
Whatβs inside?
β Live & recorded classes with Indiaβs top educators
β 200+ mock tests to track your progress
β Study materials - PYQs, workbooks, formula book & more
β 1:1 mentorship & AI doubt resolution for instant support
β Interview prep for IITs & PSUs to help you land opportunities
Learn from Experts Like:
Satish Kumar Yadav β Trained 20K+ students
Dr. Khaleel β Ph.D. in CS, 29+ years of experience
Chandan Jha β Ex-ISRO, AIR 23 in GATE
Vijay Kumar Agarwal β M.Tech (NIT), 13+ years of experience
Sakshi Singhal β IIT Roorkee, AIR 56 CSIR-NET
Shailendra Singh β GATE 99.24 percentile
Devasane Mallesham β IIT Bombay, 13+ years of experience
Use code UPSKILL30 to get an extra 30% OFF (Limited time only)
π Enroll for a free counseling session now: https://gfgcdn.com/tu/UI2/
GeeksforGeeks brings you everything you need to crack GATE 2026 β 900+ live hours, 300+ recorded sessions, and expert mentorship to keep you on track.
Whatβs inside?
β Live & recorded classes with Indiaβs top educators
β 200+ mock tests to track your progress
β Study materials - PYQs, workbooks, formula book & more
β 1:1 mentorship & AI doubt resolution for instant support
β Interview prep for IITs & PSUs to help you land opportunities
Learn from Experts Like:
Satish Kumar Yadav β Trained 20K+ students
Dr. Khaleel β Ph.D. in CS, 29+ years of experience
Chandan Jha β Ex-ISRO, AIR 23 in GATE
Vijay Kumar Agarwal β M.Tech (NIT), 13+ years of experience
Sakshi Singhal β IIT Roorkee, AIR 56 CSIR-NET
Shailendra Singh β GATE 99.24 percentile
Devasane Mallesham β IIT Bombay, 13+ years of experience
Use code UPSKILL30 to get an extra 30% OFF (Limited time only)
π Enroll for a free counseling session now: https://gfgcdn.com/tu/UI2/
π2
π‘Use ZIP function to iterate over multiple lists simultaneously π‘
#pythontips #codingtips #python #pythonprogramming #codesmarter #coding
#pythontips #codingtips #python #pythonprogramming #codesmarter #coding
π2
Tech interviews ask candidates to invert binary trees while their real job is 90% figuring out why a 3rd-party API returns null sometimes.
π5