BackmediumUncategorized uncategorized medium

Non Descending Subsequence Length Solution

Problem Statement

Given an array of integers `values`, determine the length of the longest subsequence where every element is greater than or equal to the previous one.

Example 1
Input
[1, 2, 3, 1, 4, 5]
Output
5

Explanation: The longest non-decreasing subsequence is [1, 2, 3, 4, 5].

Constraints

  • 1 <= values.length <= 1000
  • -10^4 <= values[i] <= 10^4
  • values contains at least one integer.
  • No two elements in values are required to be distinct.
  • Values array is not guaranteed to be sorted.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free