Loading topic
dp[i] is the length of the longest strictly increasing subsequence that ends at index i. It also assumes you can read Python lists and loops comfortably.3 min readdp[i] is the length of the longest strictly increasing subsequence ending at index i. It also assumes you can read basic Python and are comfortable with Big-O notation. Binary search comes in the next chapter. Here the 3 min readtails[k] holds the smallest ending value of any strictly increasing subsequence of length k + 1 seen so far, and the array is always sorted. It also assumes you can use binary search on a sorted list and read Big-O notation3 min readbisect module searches a sorted list. The only new idea here is one character in a function name, and it changes which problem the algorithm solves.3 min readbisect_left and when to use bisect_right. Here we take two common problems and turn each one into an LIS problem. Once the input is in the right shape, the algorithm you already have does the rest.3 min readdp[i] is the length of the longest strictly increasing subsequence ending at index i. It also assumes you can read nested Python loops. Here the goal changes from finding the length of the LIS to finding how many diff3 min readdp[i] is the length of the longest increasing subsequence ending at index i. It also assumes you have seen a Fenwick tree (binary indexed tree) used for prefix sums. Here the Fenwick tree keeps a prefix **maxim3 min read