Tag: dynamic programming algorithm
Given an array A of integers, return the length of the longest arithmetic subsequence in A. Recall that a subsequence of A is a list A, A, …, A …
Catalan numbers are popular in Combinatoric Mathematics. Many interesting counting problems tend to be solved using the Catalan numbers. The first few Catalan numbers are: 1, 1, 2, 5, …
A sequence X_1, X_2, …, X_n is fibonacci-like if: n >= 3 X_i + X_{i+1} = X_{i+2} for all i + 2 <= n Given a strictly increasing array …
You have some coins. The i-th coin has a probability prob of facing heads when tossed. Return the probability that the number of coins facing heads equals target if …
There is a fence with n posts, each post can be painted with one of the k colors. You have to paint all the posts such that no more …