Dynamic Programming Interview Questions and Answers
Ques 11. Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) that has the largest product.
Example:
Input: [2, 3, -2, 4], Output: 6 (subarray [2, 3])
Ques 12. Decode Ways
A message containing letters from A-Z can be encoded into numbers. Given a non-empty string containing only digits, determine the total number of ways to decode it.
Example:
Input: "226", Output: 3 ("22" can be decoded as "BB", "2" + "2" + "6" can be decoded as "VVF")
Ques 13. Word Break Problem
Given a non-empty string and a dictionary of words, determine if the string can be segmented into a space-separated sequence of one or more dictionary words.
Example:
Input: s = "leetcode", wordDict = ["leet", "code"], Output: true
Ques 14. Count Palindromic Subsequences
Given a string, find the number of distinct palindromic subsequences of it.
Example:
Input: "bccb", Output: 6 ("b", "c", "c", "b", "ccb", "bccb")
Ques 15. Minimum Path Sum
Given a grid filled with non-negative numbers, find a path from the top-left to the bottom-right corner that minimizes the sum of numbers along the path.
Example:
Grid: [[1,3,1],[1,5,1],[4,2,1]], Output: 7 (1 -> 3 -> 1 -> 1 -> 1)
Most helpful rated by users: