I’ve always wanted to learn recursion but never actually went beyond fibonacci number and factorial, with lot more time on my hands due to lockdown tried to solve a few not so trivial problems.

  1. Permutations (https://leetcode.com/problems/permutations/)
given an array [1,2,3] find all permutations[
[1,2,3],
[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
  • The idea is quite simple but let me explain how to think through this problem
  • Start with an empty array [ ]
  • Now _ _ _ in the first spot I can place any of the 3 numbers, I start with number 1.
  • 1 is rooted to the first…

Shirish Veerabattini

Programming, Soccer, gaming, photography, food and drinks 😊

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store