Category: LeetCode

  • Roman to Integer

    Leetcode qs.13Python code solution and explanation question Given a roman numeral, convert it to an integer. Example Input: s = “MCMXCIV” Output: 1994 Explanation: M = 1000, CM = 900, XC = 90 and IV = 4. thoughts Once you’ve understood the question, what we basically need to do is find a way to tell…

  • Climbing Stairs

    Leetcode qs.70Python code solution and explanation Question You are climbing a staircase. It takes n steps to reach the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example Input: n = 2 Output: 2 Explanation: There are two ways to climb to…