As reported: Visa Staff Software Engineer (Bangalore), round 1 — problem solving and system design (2026): the longest strictly increasing subsequence, solved with an
O(n²)DP; follow-up: optimize it (the binary-search approach).
Given an integer array nums, return the length of the longest strictly increasing subsequence (elements in their original order, not necessarily contiguous).
This is LeetCode 300 — Longest Increasing Subsequence.
Example
nums = [10,9,2,5,3,7,101,18] -> 4 ([2,3,7,101])
nums = [0,1,0,3,2,3] -> 4
nums = [7,7,7,7,7,7,7] -> 1
Constraints: 1 ≤ nums.length ≤ 2500; -10^4 ≤ nums[i] ≤ 10^4.
Follow-ups
- Optimize the
O(n²)solution.
Code runner format: one JSON value per line: nums. Implement lengthOfLIS(nums); the harness prints the length.