LeetCode Day 4: Permutations Backtracking Fundamentals

Day 4 | LeetCode Learning Journal 🚀 Today I solved Permutations (Problem 46) on LeetCode another classic backtracking problem that really strengthens recursion fundamentals. Unlike Combination Sum where we focused on reaching a target, this problem was about generating all possible arrangements of given numbers. The main challenge was making sure that each element is used exactly once in every permutation. The key learning was understanding how to: Keep track of which elements are already used. Build permutations step by step. Backtrack properly by removing the last element and marking it unused after recursion. Instead of randomly arranging numbers, I learned how the decision tree works at every level we choose one unused number, explore deeper, and then backtrack to try other possibilities. This systematic exploration ensures we generate all permutations efficiently. 💡 🌱 What I learned: • How to generate permutations using recursion • Using a visited array / boolean tracking • Proper backtracking with push and pop • Visualizing recursion as a decision tree #LeetCode #100DaysOfCode #CodingJourney #Backtracking #DSA #Day4

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories