Tag: dynamic programming
Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the difference between adjacent …
Given a string S, return the number of substrings that have only one distinct letter. Example 1: Input: S = “aaaba” Output: 8 Explanation: The substrings with one distinct …
The Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. …
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 …
You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may …