FastPrepLongest Increasing Subsequence Length
Problems/Longest Increasing Subsequence Length

Longest Increasing Subsequence Length

Apple logoApple● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Strict subsequence length and the decreasing-array result match the source at about 98%. The report is a 12-month graduate placement; finite bounds complete the interface.

Return the length of the longest strictly increasing subsequence in the nonempty integer array nums. A subsequence preserves the original order but may skip elements.

Equal values cannot extend a strictly increasing subsequence. A nonempty decreasing or all-equal array therefore returns 1.

Function

lengthOfLIS(nums: int[]) → int

Examples

Example 1

nums = [1,1,3,2,6,4,1,7]return = 4

One length-four increasing subsequence is [1,3,6,7].

Example 2

nums = [5,3,1]return = 1

The values only go down, so no two of them can be in the same increasing subsequence. The best you can do is a single value.

Constraints

  • 1 <= nums.length <= 10^5.
  • -10^9 <= nums[i] <= 10^9.

More Apple interview questions

  • Merge IntervalsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Merge Two Strings by Maximum Boundary OverlapOA · Seen Sep 2026
  • Collect Letters Along a Unique Grid PathOA · Seen Aug 2025
  • Maximum Weight in Two BagsOA · Seen Aug 2025
  • Ignore SectionsOA · Seen Mar 2024
  • Gas Station Circular TourOA · Seen Nov 2021
  • House Robber IIOA · Seen Nov 2021
  • Clone an Undirected Graph StateOA · Seen Mar 2021
  • Maximum Later DifferenceOA · Seen Feb 2021
  • Topological OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
  • Minimum Cost to Attend Required CoursesVisa · OAVisa interview questions
  • Fill a Time Window with SongsMicrosoft · OAMicrosoft interview questions
  • Maximum Taxi EarningsWells Fargo · OAWells Fargo interview questions
  • Longest Increasing Subsequence from Two ArraysSquarepoint Capital · OASquarepoint Capital interview questions
  • Split Array Largest SumLinkedIn · OALinkedIn interview questions
  • Longest Increasing SubsequenceAtlassian · OAAtlassian interview questions
  • Maximum Profit from an Increasing Price TripletOdoo · OAOdoo interview questions
  • Beautiful RowNutanix · OANutanix interview questions
  • Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions

Interview reports that mention this question

  • Apple New Grad SWE Phone Screens: 12 Experiences (Part 3 of 3)
  • Apple New Grad SWE Interviews: 37 Experiences (Part 1 of 3)

Apple interview experiences

  • Apple SWE Phone Screen: Subarray Products: 1 Experience
  • Apple New Grad SWE Java, Coding and Manager Rounds: 1 Experience
  • Apple AI Coding and Related Interviews: 17 Experiences
  • Apple India SWE New Grad Interviews: 5 Experiences
All Apple interview questionsSee Apple hiring insights
Saved
class Solution {
    public int lengthOfLIS(int[] nums) {
        // Write your solution here.
    }

}
Checking account…