FastPrepLongest Increasing Subsequence
Problems/Longest Increasing Subsequence

Longest Increasing Subsequence

Amazon logoAmazon● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Amazon full-time onsite interview. The report describes a custom longest increasing subsequence problem, but does not keep the rule that makes it different. Our version uses the usual goal of returning the maximum length of a strictly increasing subsequence, and we set limits. Our version is about 62% the same as the reported question.

Given an integer array nums, return the length of its longest strictly increasing subsequence.

A subsequence is formed by deleting zero or more elements without changing the relative order of the remaining elements.

Function

lengthOfLIS(nums: int[]) → int

Examples

Example 1

nums = [10,9,2,5,3,7,101,18]return = 4

One longest strictly increasing subsequence is [2, 3, 7, 101], which has length 4.

Example 2

nums = [0,1,0,3,2,3]return = 4

The subsequence [0, 1, 2, 3] is strictly increasing and has the maximum possible length.

Example 3

nums = [7,7,7,7,7,7,7]return = 1

Equal values cannot both appear in a strictly increasing subsequence, so the maximum length is 1.

Constraints

  • 1 <= nums.length <= 2500
  • -10^4 <= nums[i] <= 10^4

More Amazon Onsite Interview questions

  • Assign Escalations to TeamsONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximum Earnings Across WarehousesONSITE INTERVIEW · Seen Nov 2026
  • Priority Message BufferONSITE INTERVIEW · Seen Nov 2026
  • Search in a Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximal SquareONSITE INTERVIEW · Seen Nov 2026
  • Serialize and Deserialize a Binary TreeONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Minimum Removals for a Nice ArrayAdobe · ONSITE INTERVIEWAdobe interview questions
  • Longest Increasing SubsequenceMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Longest Increasing SubsequenceExpedia · ONSITE INTERVIEWExpedia interview questions
  • Minimum Cost for TicketsRoku · ONSITE INTERVIEWRoku interview questions
  • Longest Increasing SubsequencePeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
  • Maximum Total Length of Non-Overlapping IntervalsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Russian Doll EnvelopesGoogle · ONSITE INTERVIEWGoogle interview questions
  • Russian Doll EnvelopesInMobi · ONSITE INTERVIEWInMobi interview questions
  • Russian Doll EnvelopesAirbnb · ONSITE INTERVIEWAirbnb interview questions
  • Longest Increasing SubsequenceByteDance · PHONE SCREENByteDance interview questions

Interview reports that mention this question

  • Amazon SDE Onsite Interview Questions: 9 Experiences

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public int lengthOfLIS(int[] nums) {
      // write your code here
    }

}
Checking account…