Skip to content

Latest commit

 

History

History
75 lines (53 loc) · 3.35 KB

README.MD

File metadata and controls

75 lines (53 loc) · 3.35 KB

Dynamic Programming

Implementation of some classical problems presented by freeCodeCamp Video Course Dynamic Programming

Fibonacci

Description:

The Fibonacci sequence is a series of numbers in which each number is the sum of the two that precede it.

The Fibonacci sequence can be described as:

f(n) = f(n - 1) + f(n - 2), n > 2;
f(0) = 0;
f(1) = 1;    

GridTraveler

Description:

Say that you are a traveler on a 2d grid. You begin in the top-left corner and your goal is to travel to the bottom-right corner. You may only move down or right.

In how many ways can you travel to the goal on a grid with dimensions m * n?

f(m, n) = f(m - 1, n) + f(m, n - 1),
f(1, 1) = 1,
f(x, 0) = 0, 0 <= x <= m,
f(0, x) = 0, 0 <= x <= n

CanSum

Description:

Write a function "CanSum(target, numbers[])" that takes in a target Sum and an array of number of arguments. The function should return a boolean indicating whether or not it is possible to generate the target Sum using numbers from the array. You may use element of the array as many times as needed. You may assume that all input numbers are non-negative

bool f(target, nums[])

HowSum

Description:

Write a function "HowSum(target, numbers[])" that takes in a target Sum and an array of number of arguments. The function should return an array containing any combination of elements that add up to exactly the targetSum. If there is no combination thats add up to the target, then return null.

If there are multiple combinations possible, you may return any single one.

List<int> f(target, nums[])

BestSum

Description:

Write a function "BestSum(target, numbers[])" that takes in a target Sum and an array of number of arguments. The function should return an array containing the shortest combination of numbers that add up to exactly target. If there is a tie for the shortest combination, you may return any one of the shortest.

List<int> f(target, nums[])

CanConstruct

Description:

Write a function "canConstruct(target, wordBank)" that accepts a target string ands an array of strings. The function should return a boolean indicating whether or not the target can be constructed by concatenating elements of the wordBank array. You may reuse elements of wordBank as many time as needed.

bool f(target, wordBank[])

CountConstruct

Description:

Write a function "countConstruct(target, wordBank)" that accepts a target string ands an array of strings. The function should return the number of ways that the target can be constructed by concatenating elements of the wordBank array. You may reuse elements of wordBank as many time as needed.

int f(target, wordBank[])

AllConstruct

Description:

Write a function "allConstruct(target, wordBank)" that accepts a target string ands an array of strings. The function should return a 2d array containing all the ways that the target can be constructed by concatenating elements of the wordBank array. Each element of the 2D array should represent one combination that constructs target. You may reuse elements of wordBank as many time as needed.

List<List<string>> f(target, wordBank[])