Day 24/100 – LeetCode Challenge 🚀 Problem: Climbing Stairs Approach: Recognized that the number of ways follows the Fibonacci pattern Used dynamic programming with two variables to store the previous results Iteratively computed the number of ways up to n Time Complexity: O(n) Space Complexity: O(1) Key takeaway: Many dynamic programming problems can be optimized by storing only the necessary previous states, reducing space complexity significantly. #LeetCode #100DaysOfCode #DSA #Java #DynamicProgramming #ProblemSolving
Muthu Suresh’s Post
More Relevant Posts
-
🚀 Day 44 Out of #365DayOfCode - LeetCode Today I worked on the Set Matrix Zeroes problem, where the goal is to modify a 2D matrix such that if any element is 0, its entire row and column are set to 0. I implemented an efficient solution with O(m × n) time complexity and optimized space usage by carefully handling matrix traversal and edge cases. This problem helped me strengthen my understanding of: 2D array manipulation In-place updates Optimizing space complexity Handling edge cases in algorithms Consistent practice is helping me improve my problem-solving skills step by step. 🚀 #DSA #Java #ProblemSolving #CodingPractice #365DaysOfCode Github link: https://lnkd.in/gGUy_MKZ
To view or add a comment, sign in
-
-
Day 32/100 – LeetCode Challenge 🚀 Problem: Regular Expression Matching Approach: Used 2D Dynamic Programming Defined dp[i][j] as whether s[0..i) matches p[0..j) Handled: . → matches any character * → zero or more occurrences of previous character Time Complexity: O(m × n) Space Complexity: O(m × n) Key takeaway: When pattern rules affect previous characters (like *), dynamic programming is often required instead of greedy logic. #LeetCode #100DaysOfCode #DSA #Java #DynamicProgramming #InterviewPrep
To view or add a comment, sign in
-
-
LeetCode Problem || Find All Possible Stable Binary Arrays II (3130)🚀 🔹 Problem Idea: We are given a number of 0s and 1s and a constraint called limit. The goal is to count the number of possible binary arrays such that no more than limit consecutive identical elements appear. 🔹 Approach: I used Dynamic Programming to track the number of valid arrays formed with: i zeros j ones and the last placed element (0 or 1). The DP state helps ensure that the consecutive limit condition is maintained while building the array. Always enjoying the process of learning and improving problem-solving skills! 💡 #LeetCode #DynamicProgramming #ProblemSolving #Java #CodingPractice #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 21 of #GeekStreak60 Today’s Problem: Dice Throw – Number of Ways to Get a Sum 🎲 Solved using Dynamic Programming, where dp[i][j] represents the number of ways to get sum j with i dice. Sliding through faces and dice, we efficiently calculated all possibilities. ⏱️ Time Complexity: O(n × x × m) 📦 Space Complexity: O(n × x) 📌 Key Takeaway: Whenever a problem involves counting ways with constraints, think Dynamic Programming! @GeeksforGeeks @NPCI #GeekStreak60 #DSA #ProblemSolving #Java #CodingChallenge #NPCI
To view or add a comment, sign in
-
-
🚀 Day 21 of #GeekStreak60 Today’s Problem: Dice Throw – Number of Ways to Get a Sum 🎲 Solved using Dynamic Programming, where dp[i][j] represents the number of ways to get sum j with i dice. Sliding through faces and dice, we efficiently calculated all possibilities. ⏱️ Time Complexity: O(n × x × m) 📦 Space Complexity: O(n × x) 📌 Key Takeaway: Whenever a problem involves counting ways with constraints, think Dynamic Programming! @GeeksforGeeks @NPCI #GeekStreak60 #DSA #ProblemSolving #Java #CodingChallenge #NPCI
To view or add a comment, sign in
-
-
🚀 Day 19 of My LeetCode Challenge Today’s problem: Find All Duplicates in an Array (LeetCode 442) 🔍 Problem Summary: Given an array of integers where each value appears once or twice and lies between 1 and n, return all elements that appear twice. 🧠 Key Insight: Since numbers are in the range 1 to n, we can use the array itself to track visited elements by marking indices negative. ⚙ Approach (O(n) time | O(1) space): ✔ Traverse the array ✔ Use value → index mapping ✔ If index already negative → duplicate found ⏱ Complexity: ✅ Time: O(n) ✅ Space: O(1) 📌 What I Learned Today: Using index mapping for in-place marking How constraints help optimize space Recognizing patterns for array-based hashing #Day19 #LeetCode #Java #DSA #CodingChallenge #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 30 of My LeetCode Journey Today I solved LeetCode 451 – Sort Characters By Frequency. 🔹 Problem Statement: Given a string s, sort the characters in decreasing order based on their frequency. 🔹 Approach (HashMap + Max Heap): 1️⃣ Use a HashMap to count the frequency of each character. 2️⃣ Use a Priority Queue (Max Heap) to sort characters by their frequency. 3️⃣ Extract characters from the heap and append them to the result string according to their frequency. ⏱ Time Complexity: O(n log k) 📦 Space Complexity: O(n) This problem helped me strengthen my understanding of HashMap, Priority Queue (Max Heap), and frequency-based sorting. #LeetCode #DSA #Java #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
#Day28 of #365DaysOfCode Today’s LeetCode practice: 🔹 Word Search (LeetCode 79) Solved a backtracking problem where I had to check whether a given word exists in a 2D board by moving horizontally or vertically through adjacent cells. 💡 Key Insight: Start exploring from every cell. If the character matches the current letter of the word, move in all 4 possible directions. Mark the cell as visited and revert the change if the path doesn’t lead to a solution. On to Day 29 🔥 #LeetCode #Java #DSA #ProblemSolving #CodingJourney #Backtracking #Recursion
To view or add a comment, sign in
-
-
Day 34/100 – LeetCode Challenge 🚀 Problem: Container With Most Water Approach: Used two pointers (left & right) Calculated area using min(height[left], height[right]) × width Moved the pointer pointing to the smaller height Updated maximum area during traversal Time Complexity: O(n) Space Complexity: O(1) Key takeaway: When maximizing area between two boundaries, moving the smaller boundary is the only way to potentially increase the result. #LeetCode #100DaysOfCode #DSA #Java #TwoPointers #ProblemSolving
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