Top Coding Interview Problems #5: Dynamic Programming
Each problem includes a short description and starter solutions in both Python and Java.
Climbing Stairs
Classic DP/Fibonacci.
Python
# Climbing Stairs
class Solution:
def solve(self, *args):
# Implement the algorithm here
pass
Java
// Climbing Stairs
class Solution {
// Implement the algorithm here.
}
House Robber
Include/exclude recurrence.
Python
# House Robber
class Solution:
def solve(self, *args):
# Implement the algorithm here
pass
Java
// House Robber
class Solution {
// Implement the algorithm here.
}
Coin Change
Minimum coins DP.
Python
# Coin Change
class Solution:
def solve(self, *args):
# Implement the algorithm here
pass
Java
// Coin Change
class Solution {
// Implement the algorithm here.
}
Longest Increasing Subsequence
DP/Binary search.
Python
# Longest Increasing Subsequence
class Solution:
def solve(self, *args):
# Implement the algorithm here
pass
Java
// Longest Increasing Subsequence
class Solution {
// Implement the algorithm here.
}
Longest Common Subsequence
2D DP.
Python
# Longest Common Subsequence
class Solution:
def solve(self, *args):
# Implement the algorithm here
pass
Java
// Longest Common Subsequence
class Solution {
// Implement the algorithm here.
}