Module dp

Source
Expand description

f(i) represents the length of LIS of nums[0..=i] which ends with nums[i]

Then we want max(f(0), f(1), …, f(n-1))

f(i) = max( if nums[i] > nums[0] { f(0) + 1 } else { 1 }, … if nums[i] > nums[i-1] { f(i-1) + 1 } else { 1 }, )

f(0) = 1

Functions§

solve