Day 98 of my 100 Days of LeetCode Challenge 🚀 Solved Longest Increasing Subsequence (LIS) — a classic Dynamic Programming + Binary Search problem. The task is to find the length of the longest strictly increasing subsequence in an array. Approach used in my solution (Optimized O(n log n)): • Maintained a list res to store the smallest possible tail value for increasing subsequences of different lengths • If the current number is greater than the last element in res, append it • Otherwise, use binary search to find the correct position and replace the element • The size of res at the end gives the length of LIS Important Insight: The list does not store the actual LIS, but it maintains optimal subsequence tails to guarantee maximum possible length. Time Complexity: O(n log n) Space Complexity: O(n) This problem is a huge milestone in understanding advanced DP optimization techniques. #100DaysOfCode #100DaysOfLeetCode #LeetCode #DynamicProgramming #BinarySearch #LIS #Java #DSA #Algorithms #CodingJourney
100 Days of LeetCode: Longest Increasing Subsequence
More Relevant Posts
-
🚀 LeetCode Problem Solved: Maximum Number of Vowels in a Substring of Given Length Today I solved LeetCode 1456 – Maximum Number of Vowels in a Substring of Given Length using the Sliding Window Technique. 🔹 Problem Statement: Given a string s and an integer k, find the maximum number of vowels in any substring of length k. 🔹 Approach: Instead of checking every substring separately, I used the Sliding Window algorithm: • Count vowels in the first window of size k • Slide the window forward one character at a time • Add the new character and remove the old one from the count • Track the maximum vowels seen so far This approach optimizes the solution to O(n) time complexity. 📌 Example: Input: s = "abciiidef", k = 3 Output: 3 Explanation: The substring "iii" contains 3 vowels, which is the maximum. 💡 Key Concepts Practiced: ✔ Sliding Window Technique ✔ String Traversal ✔ Efficient Problem Solving Consistent DSA practice on LeetCode is helping me improve my algorithmic thinking and coding efficiency. #LeetCode #DSA #SlidingWindow #ProblemSolving #CodingPractice #Java #LearningInPublic #Programming
To view or add a comment, sign in
-
-
🚀 Day 7 of #100DaysOfDSA 🔍 Problem: Valid Anagram (LeetCode 242) Today I solved a classic string problem — checking whether two strings are anagrams. 💡 Key Idea: Instead of sorting (O(n log n)), I used a frequency count approach (O(n)). 👉 Logic: Create an array of size 26 (for a–z) Traverse both strings together Increase count for s, decrease for t If all values become 0 → strings are anagrams ✅ 🧠 Why it works: Same characters with same frequency cancel each other out. ⏱️ Complexity: Time: O(n) Space: O(1) : Always think about optimizing from brute force (O(n²)) to optimal (O(n)). #DSA #Java #Coding #LeetCode #Programming #SoftwareEngineering 🍁 Saidhanya Sree
To view or add a comment, sign in
-
-
Day 71 - LeetCode Journey Solved LeetCode 64: Minimum Path Sum (Medium) today — a classic grid-based dynamic programming problem. The challenge is to move from the top-left corner to the bottom-right corner of the grid while minimizing the sum of all numbers along the path. The only allowed moves are right or down, which makes this a perfect candidate for DP. 💡 Core Idea: Each cell represents the minimum cost required to reach that cell. To reach cell (i, j) we can come from: • Top → (i-1, j) • Left → (i, j-1) So the transition becomes: grid[i][j] += min(grid[i-1][j], grid[i][j-1]) By updating the grid in-place, we gradually build the minimum path cost for every cell until we reach the final destination. ⚡ Key Learning Points: • Applying Dynamic Programming on grids • Using in-place optimization to reduce space • Understanding state transition from top and left cells • Achieving O(m × n) time complexity Problems like this build strong foundations for many advanced DP questions involving paths, matrices, and grid traversal. ✅ Stronger understanding of grid DP ✅ Better optimization mindset ✅ Improved problem-solving patterns Step by step, the DSA journey continues 🚀 #LeetCode #DSA #Java #DynamicProgramming #GridDP #Algorithms #ProblemSolving #CodingJourney #Consistency #100DaysOfCode #InterviewPreparation #DeveloperGrowth #KeepCoding
To view or add a comment, sign in
-
-
Day 4 — Pattern-Based DSA Practice Continuing to learn and build in public while solving problems pattern by pattern. Today's focus: Binary Search on Rotated Arrays & Peaks Problems solved: • Count Occurrences — Coding Ninjas • Minimum Element in Rotated Sorted Array — LeetCode • Number of Times Array is Rotated — CodeChef • Find Peak Element — LeetCode Key learning: Binary Search is not always applied on perfectly sorted arrays. It can also be extended to rotated arrays and peak-based problems by carefully analyzing conditions. Instead of searching for a target, many problems are about identifying the correct region where the answer lies. Slowly understanding how the same pattern adapts to different scenarios with slight logical changes. #DSA #BinarySearch #ProblemSolving #LearningInPublic #Java #CodingJourney
To view or add a comment, sign in
-
Today I solved LeetCode 39 – Combination Sum. 🧩 Problem Summary: Given an array of distinct integers candidates and a target integer target, return all unique combinations of candidates where the chosen numbers sum up to the target. The same number may be chosen multiple times. 💡 Key Concepts Used: Backtracking Recursion Depth First Search (DFS) Combination generation 🧠 Approach: Use backtracking to explore all possible combinations. Start from an index and try adding each candidate number. If the current sum equals the target, store the combination. If the sum exceeds the target, stop exploring that path. Allow reuse of the same number by continuing recursion with the same index. 📚 What I Learned: How to generate combinations where elements can be reused. Efficient pruning when the sum exceeds the target. The importance of controlling the starting index to avoid duplicate combinations. How recursion helps explore multiple decision paths. Practicing DSA every day to strengthen problem-solving skills 💪 One step closer to becoming a better developer 🚀 #LeetCode #DSA #Backtracking #Recursion #CombinationSum #CodingJourney #Java #ProblemSolving #100DaysOfCode #TechGrowth
To view or add a comment, sign in
-
-
🚀 Day 522 of #750DaysOfCode 🚀 Today I solved the LeetCode problem “Minimum Changes To Make Alternating Binary String.” 🔹 Problem: Given a binary string consisting of 0s and 1s, we need to make the string alternating (no two adjacent characters are the same). In one operation, we can flip any character (0 → 1 or 1 → 0). The goal is to find the minimum number of operations required. 🔹 Key Idea: An alternating string can only follow two possible patterns: 1️⃣ 010101... 2️⃣ 101010... So we: Count mismatches assuming the string starts with '0'. The other pattern mismatches will be n - mismatch. The minimum of these two values gives the answer. 🔹 Time Complexity: O(n) – we traverse the string once. 📌 Example Input: "1111" Possible alternating strings → "0101" or "1010" Minimum operations → 2 Problems like this highlight how pattern observation can simplify the solution. #leetcode #programming #coding #java #softwaredevelopment #dsa #problemSolving #750DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 16/100 Days of Code Challenge Solved the classic “Sort Colors” problem (LeetCode 75) today! 🎯 🔹 Problem Summary: Given an array containing 0s, 1s, and 2s (representing colors), sort them in-place without using built-in sort. 🔹 Approach Used: Maintained three pointers: low, mid, high Efficiently partitioned the array in a single pass 🔹 Key Learning: ✔️ In-place sorting can be done in O(n) time ✔️ Using pointers smartly avoids extra space 💡 Time Complexity: O(n) 💡 Space Complexity: O(1) 🔹 Code Highlight : Used swapping and pointer movement to organize elements in one traversal. Consistency is the key 🔑 — one step closer to mastering DSA! #Day16 #100DaysOfCode #DSA #Java #CodingChallenge #LeetCode #ProblemSolving #TechJourney
To view or add a comment, sign in
-
-
🚀 LeetCode Problem Solved: Maximum Average Subarray I Day 14 of #75DaysofLeetCode Today I solved LeetCode 643 – Maximum Average Subarray I using the Sliding Window Technique. 🔹 Problem: Given an integer array nums and an integer k, find a contiguous subarray of length k that has the maximum average value. 🔹 Key Idea: Instead of recalculating the sum of every subarray of size k, we use the Sliding Window approach to update the sum efficiently by: • Adding the next element • Removing the previous element from the window This reduces the time complexity from O(n × k) to O(n). 💡 Concept Used: ✔ Sliding Window Algorithm ✔ Efficient Array Traversal ✔ Optimized Time Complexity 📌 Example: Input: nums = [1,12,-5,-6,50,3], k = 4 Output: 12.75 ✨ What I Learned: This problem helped me strengthen my understanding of window-based optimization techniques, which are very useful in many array and string problems. 🔗 Practicing data structures and algorithms consistently to improve problem-solving skills. #LeetCode #DSA #SlidingWindow #ProblemSolving #CodingPractice #Java #LearningInPublic #Programming
To view or add a comment, sign in
-
-
Friday Learning: A Simple Trick That Saves Time Today I solved LeetCode 3567 — and almost overcomplicated it. At first, I thought: “Compare every pair inside the submatrix” → O(n²) But then I realized something simple 👇 Sort the elements. Once sorted, the minimum absolute difference will ALWAYS be between adjacent values. Approach: • Extract k × k submatrix • Remove duplicates (HashSet) • Sort elements • Check adjacent differences Complexity: O(m × n × k² log k) Lesson: Sometimes the best optimization isn’t a complex data structure… It’s just recognizing the pattern. Building consistency, one problem at a time. - Ishwar Chandra Tiwari | CodeWithIshwar #leetcode #dsa #programming #java #developers #coding #buildinpublic
To view or add a comment, sign in
-
🚀 Day 10 – LeetCode Practice Today, I solved the Trapping Rain Water problem on LeetCode: 🎯 Difficulty: Hard 💻 Language Used: Java 💡 Approach: • Given an elevation map represented by an array, the task was to determine how much rainwater can be trapped after raining. • I used a two-pointer technique with left & right pointers moving inward: – Tracked max height from both ends (leftMax, rightMax). – At each step, water trapped is based on the smaller max height minus current height. – Moving pointers inward ensures efficient calculation in one pass. ⏱ Complexity: • Time Complexity: O(n) • Space Complexity: O(1) 📚 Key Takeaway: This problem reinforced how two-pointer strategies can optimize otherwise naïve solutions and how keeping track of boundary conditions leads to efficient space-constant algorithms. Consistent problem-solving practice continues to strengthen my algorithmic intuition and implementation skills. 💪 #LeetCode #Java #DSA #TwoPointers #Algorithms #ProblemSolving #CodingPractice #100DaysOfCode #SoftwareDeveloper
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