Longest Increasing Subsequence
Given an integer array nums, return the length of its longest strictly increasing subsequence.
A subsequence is what remains after deleting any number of elements (possibly none) without changing the order of the rest. It doesn't have to be contiguous. "Strictly increasing" means every element is larger than the one before it, so equal values can't be neighbours in it.
Constraints
1 <= nums.length <= 2500-10^4 <= nums[i] <= 10^4
Examples
Example 1
Input: nums = [3,1,8,2,5,9,4,6] Output: 4
For example 1, 2, 5, 9 or 1, 2, 4, 6. No increasing subsequence of length 5 exists.
Example 2
Input: nums = [4,4,4] Output: 1
Strictly increasing: equal values can't follow each other, so any single 4 is the longest.
Example 3
Input: nums = [1,3,6,7,9,4,10,5,6] Output: 6
1, 3, 6, 7, 9, 10. The 4, 5, 6 near the end start a shorter chain.
JavaScript you'll use: Arrays: create, read, update Iterating and transforming arrays
/**
* @param {number[]} nums
* @return {number}
*/
function lengthOfLIS(nums) {
}
Ctrl/⌘ + ' runs the examples, Ctrl/⌘ + Enter submits. Use console.log freely: output shows under Console. In the editor, press Esc then Tab to move focus out.