As reported: xAI frontend interview (2025), the LeetCode-style question: find the length of the longest growing (increasing) subsequence in an array.
Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence keeps the original order but may skip elements.
This is LeetCode 300 — Longest Increasing Subsequence.
Examples
[10,9,2,5,3,7,101,18] -> 4 e.g. 2, 3, 7, 101
[0,1,0,3,2,3] -> 4
[7,7,7,7,7,7,7] -> 1
Constraints: 1 ≤ nums.length ≤ 2500; -10^4 ≤ nums[i] ≤ 10^4.
Code runner format: one JSON value per line (LeetCode's test-case format): nums. Implement lengthOfLIS(nums); the harness prints the length.