data-structures · intermediate · ~15 min
Find the LIS length of an array.
Implement:
int lis(const int *a, int n);
Return the length of the longest strictly increasing subsequence of a[0..n-1].
Array a, count n.
LIS length.
O(n^2) DP is fine for the tested sizes.
#include <stddef.h>
/* Length of the Longest strictly Increasing Subsequence of a[0..n-1]. */
int lis(const int *a,int n){ (void)a;(void)n; return 0; }
Requiring contiguity — a subsequence may skip elements.
n==0 -> 0; a flat array -> 1.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.