📅 Day 41 of #100DaysOfLeetCode 🧩 Problem: 300. Longest Increasing Subsequence Difficulty: Medium 🚀 What I learned today: Used the Patience Sorting technique to solve LIS in O(n log n) time Maintained an auxiliary array where each index represents the minimum possible tail of an increasing subsequence of that length Applied binary search (lower bound / ceil) to efficiently replace elements Important insight: Using >= ensures the subsequence remains strictly increasing 🧠 Key Takeaway: Even though the auxiliary array doesn’t store the actual subsequence, its length always equals the LIS length — a powerful optimization over the classic DP O(n²) approach. 💡 Complexity: Time: O(n log n) Space: O(n) #LeetCode #Java #ProblemSolving #CodingChallenge #100DaysOfCode #DSA #LearningEveryday
Longest Increasing Subsequence in O(n log n) Time with Patience Sorting
More Relevant Posts
-
📅 Day 46 of #100DaysOfLeetCode 🧩 Problem: 2054. Two Best Non-Overlapping Events ⚙️ Difficulty: Medium 🚀 What I learned today: How to maximize value by selecting at most two non-overlapping intervals Importance of sorting events by end time to enable efficient lookups Used prefix maximum array to store the best value so far Applied binary search to find the last event that ends before the current one starts Achieved an optimal O(n log n) solution for large constraints 🧠 Key Insight: Instead of checking all pairs, precompute the best past event and combine it smartly using binary search. 💡 Techniques Used: Sorting • Binary Search • Prefix Max • Greedy ⏱ Complexity: Time: O(n log n) Space: O(n) #LeetCode #Java #ProblemSolving #CodingChallenge #100DaysOfCode #DSA #LearningEveryday
To view or add a comment, sign in
-
-
🔹 Day 96 – LeetCode Practice 📌 Problem: First Missing Positive (LeetCode #41) 📊 Difficulty: Hard 🧠 Problem Overview: Given an unsorted integer array, the task is to find the smallest positive integer that is missing from the array. The challenge lies in solving it efficiently with strict constraints on time and space. ✅ Approach Used: Stored all values from the array for quick lookup. Iterated from the smallest possible positive integer to identify the first missing value. Returned the earliest number that was not present. 📈 Submission Results: Status: Accepted ✅ Runtime: 14 ms Memory Usage: 93.44 MB 💡 Reflection: This problem highlights the importance of understanding constraints clearly. While multiple approaches exist, optimizing time and space is the key learning takeaway from this question. #LeetCode #DSA #ProblemSolving #Arrays #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 147 | Frequency Counting Across Multiple Strings Today’s problem was a clean exercise in comparing character frequencies across multiple inputs. 🧩 Problem Solved: 1002. Find Common Characters 🔍 Approach: • Initialized a frequency array using the first word. • For each subsequent word, counted character frequencies and kept the minimum count for each character. • Constructed the result by adding each character as many times as its final minimum frequency. ✨ Key Insight: Using minimum frequency across all strings ensures only truly common characters are included. 📚 Topics: Hashing · Strings · Frequency Counting 💻 Platform: LeetCode #LeetCode #DSA #ProblemSolving #DailyCoding #Strings #Hashing #Java #Consistency
To view or add a comment, sign in
-
-
day 92/100 #leetcodegrinding The number of rotations equals the index of the minimum element in the array. Using binary search, we can find this efficiently in O(log n) time. 🧠 What I focused on: Identifying the pivot (minimum element) Handling rotated vs non-rotated cases Applying binary search with correct boundaries Writing a clean and efficient Java solution This problem really strengthens understanding of rotated arrays and search logic. Keeping the streak alive 🚀 #DSA #ProblemSolving #Java #BinarySearch #Arrays #LeetCode #CodingPractice #DailyLearning
To view or add a comment, sign in
-
-
🚀 Day 44 of #100DaysOfCode Solved LeetCode Problem #961 – N-Repeated Element in Size 2N Array This problem was about identifying the element that repeats N times in an array of size 2N. The key insight is that the repeated element must appear very close to itself, allowing an efficient linear scan without extra space. Key Learnings: -> Used observation-based logic instead of extra data structures -> Checked only nearby indices to detect repetition early -> Achieved optimal O(n) time and O(1) space -> Reinforced pattern recognition in array problems Language Used: Java -> Runtime: 0 ms (Beats 100.00%) -> Memory: 47.85 MB Small observations can lead to optimal solutions 🚀 #LeetCode #Java #Arrays #ProblemSolving #100DaysOfCode #DSA
To view or add a comment, sign in
-
-
#Day_59 Problem: 4Sum (LeetCode 18) Day 57 pushed the limits with 4Sum — finding all unique quadruplets equal to a target! 💥 🧠 Key Takeaways: This is an extension of 3Sum → fix two elements + two pointers. Sorting is the backbone. Duplicate skipping at both outer and inner levels is critical. Use long for sum to avoid overflow. ⚙️ Optimized Approach: Sort the array. Fix i and j. Apply two pointers for remaining part. Carefully skip duplicates. ⏱️ Complexity: O(n³), but still efficient compared to brute force. 📌 This problem taught me: How patterns scale from 2Sum → 3Sum → 4Sum. Writing clean, duplicate-free logic. Consistency + patterns = confidence! 💪 #Day57 #4Sum #LeetCode #Java #DSA #CodingPractice #LearnByDoing
To view or add a comment, sign in
-
-
Day 18 of my LeetCode Journey: Problem: Search in a 2D Matrix Approach: Started from the top-right corner of the matrix. At each step: If the value is greater than target → move left If smaller → move down If equal → found the target This works because rows and columns are both sorted, allowing us to eliminate one row or column at every step. Time Complexity: O(m + n) Space Complexity: O(1) Key insight: Using matrix properties smartly can avoid unnecessary binary searches. Using matrix properties smartly can avoid unnecessary binary searches. On to Day 19 💪 #LeetCode #DSA #Java #ProblemSolving #CodingJourney #Consistency #1001DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 97 of #100DaysofChallenge 🚀 Today’s LeetCode Daily Question focused on analyzing strings column-wise and making smart decisions to preserve sorted order. Problem: Delete Columns to Make Sorted Approach: Iterated through each column of the string array Compared characters row by row to check lexicographical order Deleted a column immediately when an order violation was found ✅ Runtime: 8 ms — Beats 74.40% ✅ Memory: 47.15 MB ✅ *86 / 86 test cases passed Key Takeaways: Sometimes a simple greedy check is all you need Early breaks help optimize performance Column-wise thinking is essential in string matrix problems Just 3 days left to complete this journey — consistency really pays off #Day97 #100DaysOfCode #LeetCode #DailyChallenge #Java #DSA #ProblemSolving #Consistency #CodingJourney #TechGrowth
To view or add a comment, sign in
-
-
Today Morning,With the fresh morning, I solved the Reverse Integer problem on LeetCode. Instead of directly reversing the number, I focused first on handling edge cases — especially integer overflow. 🔍 Key Insight: Before pushing a digit into the reversed number, I checked whether the value would exceed the 32-bit integer range (Integer.MAX_VALUE / Integer.MIN_VALUE). This ensures correctness even for tricky inputs like 1534236469. 💡 What I learned: Always validate constraints before implementation Edge cases can make or break a solution Writing safe, overflow-aware code is crucial for real-world systems Consistently practicing DSA problems to sharpen logic and build strong fundamentals. On to the next challenge! 💪 Github link https://lnkd.in/gGUy_MKZ #LeetCode #DSA #Java #ProblemSolving #CodingPractice #LearningEveryDay
To view or add a comment, sign in
-
-
Day 14/100 – LeetCode Challenge ✅ Problem: #1048 Longest String Chain Difficulty: Medium Language: Java Approach: Dynamic Programming with Memoization & Preprocessing Time Complexity: O(n × L²) where n = words, L = word length Space Complexity: O(n) Key Insight: A word chain is formed if we can add one letter anywhere to predecessor. Preprocess by grouping words by length for efficient predecessor search. Use DFS + memoization to find longest chain for each word. Solution Brief: Mapped words by length for quick access. For each word, tried removing each character to find predecessors. Recursively computed chain length with memoization (dp map). Building word connections through character manipulation. #LeetCode #Day14 #100DaysOfCode #DynamicProgramming #Java #Algorithm #CodingChallenge #ProblemSolving #LongestStringChain #MediumProblem #Memoization #StringManipulation #DSA #HashMap
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