Skip to content

Commit 38f0cbd

Browse files
committed
Merge branch 'develop'
Chapter 17: Dynamic Programming
2 parents 2a23200 + 9148476 commit 38f0cbd

27 files changed

+752
-0
lines changed

dynamicprogramming/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Chapter 17: Dynamic Programming
2+
3+
* 17.1 ComputeScoreCombinations
4+
* 17.2 ComputeLevenshtein
5+
* 17.3 CountPossibleTraversals
6+
* 17.4 ComputeBinomialCoefficients
7+
* 17.5 SearchSequence2D
8+
* 17.6 KnapsackProblem
9+
* 17.7 BedBathBeyondProblem
10+
* 17.8 MinimumWeightPathTriangle
11+
* 17.9 MaximumCoinsGain
12+
* 17.10 CountMovesToClimbStairs
13+
* 17.11 PrettyPrintingProblem
14+
* 17.12 LongestNondecreasingSubsequence

dynamicprogramming/pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>elements-of-programming-interviews</artifactId>
7+
<groupId>gardncl</groupId>
8+
<version>1.0</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>dynamicprogramming</artifactId>
13+
<name>Chapter 17: Dynamic Programming</name>
14+
<dependencies>
15+
<dependency>
16+
<groupId>gardncl</groupId>
17+
<artifactId>datastructures</artifactId>
18+
<version>1.0</version>
19+
</dependency>
20+
</dependencies>
21+
22+
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import java.util.Collections;
2+
import java.util.List;
3+
import java.util.Set;
4+
5+
public class BedBathBeyondProblem {
6+
7+
/*
8+
17.7
9+
10+
Given a dictionary, i.e., a set of strings, and a name,
11+
design an efficient algorithm that checks whether the
12+
name is the concatenation of a sequence of dictionary
13+
words. If such a concatenation exists, return it.
14+
*/
15+
16+
public static List<String> decompose(String domain, Set<String> dictionary) {
17+
18+
return Collections.emptyList();
19+
}
20+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class ComputeBinomialCoefficients {
2+
3+
/*
4+
17.4
5+
6+
Design an efficient algorithm for computing (n choose k)
7+
which has the property that it never overflows if the
8+
final result fits in the integer work size.
9+
*/
10+
11+
public static int compute(int n, int k) {
12+
13+
return 0;
14+
}
15+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class ComputeLevenshtein {
2+
3+
/*
4+
17.2
5+
6+
Write a program that takes two strings and
7+
computes the minimum number of edits needed
8+
to transform the first string into the
9+
second string.
10+
*/
11+
12+
public static int levenschteinDistance(String A, String B) {
13+
14+
return 0;
15+
}
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import java.util.List;
2+
3+
public class ComputeScoreCombinations {
4+
5+
/*
6+
17.1
7+
8+
Write a program that takes a final score and scores for
9+
individual plays, and returns the number of combinations
10+
of plays that result in teh final score.
11+
*/
12+
13+
public static int compute(int finalScore, List<Integer> playScores) {
14+
15+
return 0;
16+
}
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class CountMovesToClimbStairs {
2+
3+
/*
4+
17.10
5+
6+
Write a program which takes as inputs n and k and
7+
returns the number of ways in which you can get
8+
to your destination.
9+
*/
10+
11+
public static int numberOfWays(int top, int maximumStep) {
12+
13+
return 0;
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class CountPossibleTraversals {
2+
3+
/*
4+
17.3
5+
6+
Write a program that counts how many ways you
7+
can go from the top-left to the bottom-right
8+
in a 2D array.
9+
*/
10+
11+
public static int numberOfWays(int n, int m) {
12+
13+
return 0;
14+
}
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import java.util.List;
2+
3+
public class KnapsackProblem {
4+
5+
/*
6+
17.6
7+
8+
Write a program for the knapsack problem that selects a
9+
subset of items that has maximum value and satisfies
10+
the weight constraint.
11+
12+
Tuple -> (cost,weight)
13+
*/
14+
15+
public static int compute(List<Tuple> items, int capacity) {
16+
17+
return 0;
18+
}
19+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import java.util.List;
2+
3+
public class LongestNondecreasingSubsequence {
4+
5+
/*
6+
17.12
7+
8+
Write a program that takes as input an array of numbers and
9+
returns the length of a longest nondecreasing subsequence
10+
in the array.
11+
*/
12+
13+
public static int compute(List<Integer> A) {
14+
15+
return 0;
16+
}
17+
}

0 commit comments

Comments
 (0)