Longest Increasing Subsequence in O(n log n) Time with Patience Sorting

📅 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

  • text

To view or add a comment, sign in

Explore content categories