Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Longest Increasing Subsequence

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Longest Increasing Subsequence. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence is formed by deleting zero or more elements without changing the order of the remaining elements.

Write a function that returns only the length, not the subsequence itself.

Formal Specification

  • Input: A list of integers nums
  • Output: An integer representing the maximum length of a strictly increasing subsequence

Constraints

  • 1 <= len(nums) <= 10^5
  • -10^9 <= nums[i] <= 10^9
  • The subsequence must be strictly increasing

Function Signature

def length_of_lis(nums):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output