You are coding as a Guest. Sign in with your RoleNest account to permanently track your streak, earn XP, and climb the Campus Leaderboard!
Sign In with RoleNestProblem Set
🔥Longest Increasing Subsequence: Patience SortMedium
DAILY PROBLEM OF THE DAY+50 XP • Daily Streak
Solve today's challenge or tackle one of the 3 Super Hard challenges for +150 XP.
MediumDynamic Programming•Acceptance: 54.6%
Longest Increasing Subsequence: Patience Sort
Targeted in FAANG & Tech OA:GoogleMicrosoftAmazon
Real-World Engineering Context
Used in version control delta diff algorithms (Git patience diff), genomic evolutionary sequence alignments, and stock trend momentum indicators.
Given an integer array `nums`, return the length of the longest strictly increasing subsequence.
A subsequence is an array that can be derived by deleting some or no elements without changing the order of the remaining elements.
Can you achieve `O(n log n)` time complexity?
Sample Test Cases
Input: [[10,9,2,5,3,7,101,18]]
Expected: 4
Input: [[0,1,0,3,2,3]]
Expected: 4
Input: [[7,7,7,7,7,7,7]]
Expected: 1
Constraints
- 1 <= nums.length <= 2500
- -10^4 <= nums[i] <= 10^4
Recruiter Fast-Track ReferralVerified Candidate
Direct pipeline to Google, Amazon, Microsoft, Swiggy, & Uber recruiters
Top DevScore profiles bypass resume screening filters. Every verified problem solve writes authentic proof-of-work to your profile and dispatches you directly into employer inboxes on RoleNest.
Explore 5,000+ Direct ATS Openings on RoleNest ↗✓ Direct Referral Active
Language:
Ready to test. Click Run Code or Submit Solution to run test cases in isolated browser sandbox.