Posts

Showing posts from September, 2022

LeetCode 91. Decode Ways

Image
 Today, I continued with exploring dynamic programming problems. So, I came across this problem  Decode Ways - LeetCode .  Problem: This problem description says that there is an inherent mapping in between Alphabets and numbers.  We would be provided with string of numbers, and we have to count unique number of ways to decode it. For example, if given string of numbers is  "11106"  then it can be broken down into two groupings: Note that the grouping  (1 11 06)  is invalid because  "06"  cannot be mapped into  'F'  since  "6"  is different from  "06". Given a string like this we need to return number of ways for breaking down this string into valid alphabet. Solution and thought Process: We can break down this problem recursively. I do generally follow HIB (Hypothesis Induction Base condition) based approach for solving any kind of recursion problem. Let's focus first on Hypothesis and Induction step: any valid stri...