All practice tasks

Coding (Algo)

Longest Rising Sequence

Binary search · Medium

A trend analyzer can ignore noisy measurements but must preserve their order. It needs the greatest number of selected readings that rise strictly from one selected reading to the next. A consecutive rising run is not sufficient.

Return the length of the longest strictly increasing subsequence without reconstructing the chosen values.

Input

Call

  • Implement solve(input) and return the result. The provided adapter handles JSON input and output.

Input shape

A JSON object { "nums": number[] }.

Fields

  • nums is a sequence in observation order; values may repeat or be negative.

Output

Return value

  • Return an integer length. Selected indexes increase but need not be adjacent.
  • Equal values do not extend the sequence. Empty input returns 0.

Constraints

  • At most 100000 values, each an integer in [-1000000000,1000000000].

Examples

Example 1

{
  "nums": [
    3,
    1,
    2,
    2,
    5,
    4
  ]
}

Returns

3

1,2,5 and 1,2,4 both qualify.

Example 2

{
  "nums": [
    2,
    2,
    2
  ]
}

Returns

1

Equality does not count as growth.

Required complexity

O(n log(n + 1)) time and O(n) extra space

What this task practices

Longest Rising Sequence is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as medium difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.