🚀 Day 129/160 – Total Decoding Messages | Dynamic Programming Today’s challenge was about decoding numeric messages into alphabets (like 1→A, 2→B...26→Z). Used a DP approach to count all valid decoding ways efficiently. 🧠 Key takeaway: Dynamic Programming shines when a problem’s state depends on previous results — here, each position depends on the previous one and the one before it. #100DaysOfCode #GeeksforGeeks #160DaysOfDSA #DynamicProgramming #ProblemSolving #Java #CodingJourney #LearnByDoing
Decoding numeric messages with DP in Java
More Relevant Posts
-
Day 47 of #100DaysOfLeetCode Today's problem: Reverse Words in a String Language used: Java What I did today: I implemented a solution to reverse the order of words in a given string while handling extra spaces efficiently. Used split("\\s+") to handle multiple spaces. Reconstructed the reversed string using StringBuilder. Applied trim() to clean up leading and trailing spaces. Key Takeaways: split("\\s+") is great for ignoring multiple spaces. Always use trim() to ensure a neat final output. StringBuilder makes string manipulation much faster than direct concatenation. #100DaysOfCode #LeetCode #Java #CodingChallenge #ProblemSolving #Programming #DeveloperJourney #LearnToCode
To view or add a comment, sign in
-
-
🚀 Day 140 of #150DaysOfCode on LeetCode Solved: 1526. Minimum Number of Increments on Subarrays to Form a Target Array Language: Java The task was to determine the minimum number of subarray increment operations needed to build the target array from all zeros. 🔹 Intuition: Every time the current element is greater than the previous one, it means we need that many new operations to reach the next level. Decreases don’t add extra work since earlier increments already cover them. 🔹 Approach: Start with the first element’s value as the initial count. For each subsequent element, if it’s larger than the previous one, add the difference. The sum of all such differences gives the minimum number of operations required. 🔹 Complexity: Time: O(n) Space: O(1) #LeetCode #150DaysOfCode #Java #CodingChallenge #ProblemSolving #Greedy #Arrays #DSA #TechLearning #Programmer #WomenInTech #CodeJourney #DynamicProgramming
To view or add a comment, sign in
-
-
🚀 Day-74 of #100DaysOfCodeChallenge 💡 LeetCode Problem: 3370. Smallest Number With All Set Bits (Easy) 🧠 Concepts Practiced: Bit Manipulation, Binary Representation, Logical Thinking Today’s challenge was short but conceptually sharp — finding the smallest number ≥ n whose binary representation consists only of 1’s (all set bits). This problem tested understanding of bit patterns and how to efficiently generate numbers with consecutive set bits using bitwise logic. 🔹 Key Idea: Keep generating numbers of the form (1 << k) - 1 (which gives 111...1 in binary) until we find one greater than or equal to n. It’s a neat example of how mathematical patterns meet binary logic in programming! ⚙️ ⚙️ Language: Java ⚡ Runtime: 0 ms (Beats 100.00%) 💾 Memory: 40.59 MB (Beats 87.17%) ✅ Result: 608 / 608 test cases passed — Accepted 🎯 Every problem, no matter how simple, reinforces that clarity in logic is the foundation of clean code 💪 #100DaysOfCode #LeetCode #Java #CodingChallenge #BitManipulation #BinaryLogic #ProblemSolving #Programming #DeveloperJourney #LearningEveryday #TechMindset #CleanCode
To view or add a comment, sign in
-
-
💻 Day 69 of #LeetCode100DaysChallenge Solved LeetCode 264: Ugly Number II a dynamic programming problem that improves sequence generation and pointer-based optimization skills. 🧩 Problem: An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Given an integer n, return the n-th ugly number. 💡 Approach — Dynamic Programming with Three Pointers: 1️⃣ Maintain an array dp where dp[i] stores the i-th ugly number. 2️⃣ Use three pointers p2, p3, and p5 to track multiples of 2, 3, and 5 respectively. 3️⃣ At each step, choose the smallest of dp[p2]*2, dp[p3]*3, and dp[p5]*5 as the next ugly number. 4️⃣ Increment the corresponding pointer(s) to avoid duplicates. 5️⃣ Continue until the nth ugly number is found. ⚙️ Complexity: Time: O(N) — one pass to generate all ugly numbers Space: O(N) — for storing the sequence ✨ Key Takeaways: ✅ Strengthened understanding of pointer-based DP techniques. ✅ Learned how to efficiently generate sorted multiplicative sequences. ✅ Practiced optimization over brute-force factor checking. #LeetCode #100DaysOfCode #Java #DynamicProgramming #TwoPointers #Math #DSA #ProblemSolving #CodingJourney #WomenInTech
To view or add a comment, sign in
-
-
"Exploring the Magic of Loops in Java! 💻✨ From simple triangles to complex symmetric designs, star patterns are more than just beginner exercises — they’re a creative way to master logic, loops, and nested conditions! Here’s my deep dive into different star pattern programs in Java — each one crafted to teach how iterations and conditions interact to create stunning console outputs. Programming isn’t just about solving problems; it’s about creating beauty through logic. 🌟 #JavaProgramming #CodingJourney #PatternLogic #ProgrammersLife #CodeArt #TechLearning #StarPattern #LogicBuilding"
To view or add a comment, sign in
-
📌 Day 18/100 - Valid Palindrome (LeetCode 125) 🔹 Problem: Determine whether a string reads the same forward and backward, ignoring case and non-alphanumeric characters. 🔹 Approach: Implemented a two-pointer technique. Skipped all non-alphanumeric characters. Compared characters from both ends in lowercase. Returned true if all matched, otherwise false. 🔹 Key Learning: Two-pointer method keeps logic clean and efficient. Character handling is key when data isn’t uniform. Time complexity: O(n), Space complexity: O(1). Sometimes, solving elegantly is better than solving fast. ✨ #100DaysOfCode #LeetCode #Java #ProblemSolving #DSA #CodingJourney
To view or add a comment, sign in
-
-
✅ Day 69 of LeetCode Medium/Hard Edition Today’s challenge was “Number of Ways to Stay in the Same Place After Some Steps” — a classic Dynamic Programming problem blending recursion, state transitions, and boundary control 🧭⚙️ 📦 Problem: You start at index 0 in an array of length arrLen. In each step, you can: 1️⃣ Move right by one position 2️⃣ Move left by one position 3️⃣ Stay in the same place Your goal: Find the number of ways to still be at index 0 after exactly steps moves, without ever going out of bounds. Return the answer modulo 1e9 + 7. 🔗 Problem Link: https://lnkd.in/gvd9mFFQ ✅ My Submission: https://lnkd.in/gwREFKts 💡 Thought Process: At each move, you have three possible transitions — stay, move left, or move right. We use top-down recursion with memoization to count all valid paths that end up at index 0. Each state can be represented as (steps, index), meaning the number of ways to reach position index with steps remaining. 🎯 Recurrence Relation: dp[steps][idx] = dp[steps - 1][idx] // stay + dp[steps - 1][idx - 1] // move left + dp[steps - 1][idx + 1] // move right ⚙️ Complexity: ⏱ Time: O(steps²) — since we only need to consider indices up to steps 💾 Space: O(steps²) — due to DP memoization 💭 Takeaway: This problem beautifully demonstrates how bounded state transitions and recursive caching can tame exponential branching into efficient dynamic programming. Sometimes, staying in place is as strategic as moving ahead 🚀 #LeetCodeMediumHardEdition #100DaysChallenge #DynamicProgramming #Recursion #Memoization #Java #ProblemSolving #DSA #CodingChallenge
To view or add a comment, sign in
-
-
✅Day 80 of #100DaysOfLeetCode 1.📌Problem: Set Mismatch You are given an array that represents a set of integers from 1 1 to n n, but due to an error, one number is duplicated and another is missing. The task is to find the duplicated number and the missing number and return them as an array. 2.🟢 Difficulty: Easy 3.📍Topic: Hashing,Array 4.🎯 Goal: Find the number that occurs twice and the number that is missing, then return them in an array. 5.🧠 key idea: Approach 1: Use a HashMap to count occurrences of each number in the input array. Identify the duplicated number by finding the one which appears twice. Compute the total sum expected (n(n+1)/2 n(n+1)/2) and compare with the actual sum (excluding the duplicate). The missing number equals the difference between the expected total and the corrected actual sum. Return the duplicate and missing numbers as the result array. #LeetCode #100DaysOfCode #CodingChallenge #Java #Programming #InterviewPrep #Algorithms #DataStructures #Hashing #ProblemSolving #Array #SoftwareEngineering #TechCareers #LearnToCode #CodeNewbie #DailyCode #ChallengeYourself
To view or add a comment, sign in
-
-
Day 43 of #50DaysOfLeetCodeChallenge Problem: Valid Parentheses Approach: Used a stack to keep track of opening brackets. For each closing bracket, checked if it matches the top of the stack. Returned false if there was a mismatch or stack was empty. This ensures all brackets are properly nested and closed. Key Takeaways: Stacks are perfect for problems involving nested structures. Simple traversal with O(n) time complexity and O(n) space. Feeling more confident handling pointers and references in Java! Performance: Using a stack this way really helped me understand how to manage nested elements efficiently. #LeetCode #Java #DSA #CodingChallenge #ProblemSolving #Stack #Programming
To view or add a comment, sign in
-
-
🎯 Day 7 of #365DaysofDSA Today I solved “Maximum Depth of Binary Tree” (LeetCode #104) 🌳 💡 Concepts used: • Recursion • Depth Calculation in Binary Trees ✨ Approach Summary: Used a recursive approach to find the longest path from the root node down to the farthest leaf node. For each node: 1️⃣ Recursively find the maximum depth of its left and right subtrees. 2️⃣ The current node’s depth = max(leftDepth, rightDepth) + 1. This elegant recursive solution divides the problem into smaller subproblems — calculating depth for subtrees and combining the results. 🚀 Key takeaway: Recursive thinking simplifies complex tree problems by leveraging the natural hierarchical structure of binary trees. 🌱 #Day7 #DSA #LeetCode #Java #BinaryTree #Recursion #ProblemSolving #CodingJourney #Programming #LearnByDoing #MaximumDepthOfBinaryTree
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development