Solve a non-standard variant of LIS

Problem Solve a non-standard variant of the Longest Increasing Subsequence (LIS) problem. The interviewer starts from classic LIS and adds a twist — a constraint on adjacency, allowed differences between consecutive picks, or grouping of elements.

Input / Output

  • Input: an array of integers (plus the variant's extra rule, stated by the interviewer).
  • Output: the length (or the subsequence) satisfying the variant's constraints.

Constraints

  • Clarify the exact twist before coding — the rules define the DP transitions.
  • Aim to match classic LIS efficiency where the variant allows.

Example

  • Classic LIS: [10,9,2,5,3,7,101,18] → 4 ([2,3,7,101]); the variant modifies which picks are legal.
asked …
LeaderboardSalaryAccount