Measure a Strictly Increasing Subsequence

Quick Overview

Measure a Strictly Increasing Subsequence. Return the maximum length of a strictly increasing subsequence of nums. A subsequence preserves index order but need not use consecutive positions. Equal values

Measure a Strictly Increasing Subsequence

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Other

### Problem Return the maximum length of a strictly increasing subsequence of nums. A subsequence preserves index order but need not use consecutive positions. Equal values cannot extend a strictly increasing sequence. ```cpp int lengthOfLIS(vector<int>& nums); ``` ### Examples ```text nums = [3,1,2,2,5,4] -> 3 nums = [6,6,6] -> 1 ``` ### Constraints - Length is 1 through 2500. - Values are between -10000 and 10000. ### Optional follow-up Can you achieve O(n log n) time?

Overview: Measure a Strictly Increasing Subsequence. Return the maximum length of a strictly increasing subsequence of nums. A subsequence preserves index order but need not use consecutive positions. Equal values

Microsoft logo
Microsoft
Sep 25, 2026
mediumSoftware EngineerOtherCoding & Algorithms
0
0

Problem

Return the maximum length of a strictly increasing subsequence of nums. A subsequence preserves index order but need not use consecutive positions. Equal values cannot extend a strictly increasing sequence.

int lengthOfLIS(vector<int>& nums);

Examples

nums = [3,1,2,2,5,4] -> 3
nums = [6,6,6] -> 1

Constraints

  • Length is 1 through 2500.
  • Values are between -10000 and 10000.

Optional follow-up

Can you achieve O(n log n) time?