Tag: dynamic programming
The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps: if x is even then x …
Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: Output: 4 Explanation: The longest increasing subsequence is , therefore the length is 4. …
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. …