The core idea behind sorting a stack using recursion is to:
- Remove elements from the stack one by one.
- Recursively sort the remaining stack.
- Insert the removed element at the correct position in the sorted stack.
Question: 349. Intersection of Two Arrays
Intution:
Time Complexity:
Space Complexity:
Solution:
Question: Row with max 1s
Intution: Not exactly binary search but we can utilize the fact that it the row is sorted. We have to use 2 pointers approach.
Time Complexity:
Space Complexity:
Solution:
Question: Frequency In A Sorted Array
Intution:
Time Complexity:
Space Complexity:
Solution:
Question: Implement Lower Bound
Intution:
Time Complexity:
Space Complexity:
Solution:
Question: Implement Upper Bound
Intution:
Time Complexity:
Space Complexity:
Solution:
Question: 153. Find Minimum in Rotated Sorted Array
Intution:
Time Complexity:
Space Complexity:
Solution:
Question: 367. Valid Perfect Square
Intution:
Time Complexity:
Space Complexity:
Solution: