Java LeetCode #91 Decode Ways Solution

Day 67 of #100DaysOfLeetCode 💻✅ Solved #91. Decode Ways problem in Java. Approach: • Checked if the input string is empty or starts with '0' • Initialized a DP array to store number of ways to decode up to each index • Used dp[i] = dp[i-1] if single digit is valid (1–9) • Added dp[i-2] if two-digit number is valid (10–26) • Returned dp[n] as the total number of decoding ways Performance: ✓ Runtime: 1 ms (Beats 99.90%) ✓ Memory: 41.5 MB (Beats 55%) Key Learning: ✓ Practiced dynamic programming with strings ✓ Strengthened understanding of single vs double digit constraints ✓ Reinforced how to build DP solutions incrementally Learning one problem every single day 🚀 #Java #LeetCode #DSA #DynamicProgramming #ProblemSolving #CodingJourney #100DaysOfCode

  • graphical user interface, application

To view or add a comment, sign in

Explore content categories