Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Dynamic Programming Interview Questions and Answers

Ques 21. Maximum Profit with K Transactions

Given an array representing stock prices, find the maximum profit that can be obtained with at most k transactions.

Example:

Input: [3, 2, 6, 5, 0, 3], k = 2, Output: 7

Is it helpful? Add Comment View Comments
 

Ques 22. Count Distinct Subsequences

Given a string, find the number of distinct non-empty subsequences of the string.

Example:

Input: "abc", Output: 7 ("a", "b", "c", "ab", "ac", "bc", "abc")

Is it helpful? Add Comment View Comments
 

Ques 23. Palindromic Substrings

Given a string, find the total number of palindromic substrings.

Example:

Input: "abc", Output: 3 ("a", "b", "c")

Is it helpful? Add Comment View Comments
 

Ques 24. Minimum Cost Path

Given a 2D grid, find the minimum cost path from the top-left corner to the bottom-right corner.

Example:

Grid: [[1,3,1],[1,5,1],[4,2,1]], Output: 7 (1 -> 3 -> 1 -> 1 -> 1)

Is it helpful? Add Comment View Comments
 

Ques 25. Word Break II

Given a non-empty string and a dictionary of words, return all possible sentences formed by concatenating words from the dictionary.

Example:

Input: s = "catsanddog", wordDict = ["cat", "cats", "and", "sand", "dog"], Output: ["cats and dog", "cat sand dog"]

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2026 WithoutBook