FastPrepLongest Increasing Subsequence
Problems/Longest Increasing Subsequence

Longest Increasing Subsequence

Microsoft logoMicrosoft● MediumNEW GRADINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report from a Microsoft Data & Applied Scientist internship names a well-known problem. It says a dynamic-programming solution was accepted without a follow-up for O(n log n). We chose the function signature and the limits. Our version is about 99% the same as the reported question.

Return the length of the longest subsequence of nums whose values are strictly increasing. A subsequence preserves original index order but may omit values.

Function

lengthOfLIS(nums: int[]) → int

Examples

Example 1

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

One longest increasing subsequence is [2,3,7,101].

Constraints

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

More Microsoft Onsite Interview questions

  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Longest Increasing SubsequenceAmazon · ONSITE INTERVIEW
  • Minimum Removals for a Nice ArrayAdobe · ONSITE INTERVIEWAdobe 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

  • Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)
  • Microsoft SWE Intern Interviews: 244 Experiences (Part 1 of 6)
  • Microsoft AI/ML Intern Interviews: 114 Experiences (Part 1 of 2)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public int lengthOfLIS(int[] nums) {
      // Write your code here.
    }

}
Checking account…