Gamified challenge · 1-D dynamic programming
Crates arrive on a conveyor in a fixed order; heights[i] is the height of crate i. You may keep any crates you like, but you can't reorder them, and every kept crate must be strictly taller than the one kept before it. Equal heights don't count as rising.
Write lis(heights) that returns the largest number of crates you can keep. An empty conveyor gives 0.
Example: for [10, 9, 2, 5, 3, 7, 101, 18] you can keep 2, 3, 7, 18 (or 2, 5, 7, 101), so the answer is 4.
This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.
Sign in with Google