Problem library

Climb Streak

Hard
dynamic programmingbinary search

ratings is a player's rating after each match. Pick any matches (keeping their order) so that the chosen ratings are strictly increasing.

Return the largest number of matches you can pick. Aim for better than O(n^2): the largest test has 50,000 ratings.

Examples

Input: ratings = [1200,1180,1250,1210,1300]
Output: 3
Input: ratings = [1500,1500,1500]
Output: 1