Most asked top Interview Questions and Answers & Online Test
Education platform for interview prep, online tests, tutorials, and live practice

Build skills with focused learning paths, mock tests, and interview-ready content.

WithoutBook brings subject-wise interview questions, online practice tests, tutorials, and comparison guides into one responsive learning workspace.

Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address
Home / Interview Subjects / Dynamic Programming
WithoutBook LIVE Mock Interviews Dynamic Programming Related interview subjects: 74

Interview Questions and Answers

Know the top Dynamic Programming interview questions and answers for freshers and experienced candidates to prepare for job interviews.

Total 30 questions Interview Questions and Answers

The Best LIVE Mock Interview - You should go through before interview

Know the top Dynamic Programming interview questions and answers for freshers and experienced candidates to prepare for job interviews.

Interview Questions and Answers

Search a question to view the answer.

Intermediate / 1 to 5 years experienced level questions & answers

Ques 1

Longest Increasing Subsequence (LIS)

Find the length of the longest subsequence of a given sequence such that all elements of the subsequence are sorted in increasing order.

Example:

Input: [10, 22, 9, 33, 21, 50, 41, 60, 80], Output: 6
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 3

0/1 Knapsack Problem

Given weights and values of items, find the maximum value that can be obtained by selecting a subset of items with total weight not exceeding a given limit.

Example:

Weights: [2, 3, 4, 5], Values: [3, 4, 5, 6], Knapsack Capacity: 5, Output: 11
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 5

Rod Cutting Problem

Given a rod of length n and prices at which different lengths of the rod can be sold, find the maximum value obtainable by cutting up the rod.

Example:

Lengths: [1, 2, 3, 4, 5], Prices: [1, 5, 8, 9, 10], Rod Length: 4, Output: 10
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 7

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")
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 8

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
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 9

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)
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 11

Partition Equal Subset Sum

Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.

Example:

Input: [1, 5, 11, 5], Output: true (subset sums: [1, 5, 5] and [11])
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 12

Maximum Length of Repeated Subarray

Given two integer arrays, find the maximum length of a common subarray of both arrays.

Example:

Input: A = [1,2,3,2,1], B = [3,2,1,4,7], Output: 3 ([3, 2, 1])
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 14

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)
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 15

Arithmetic Slices

A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. Return the total number of arithmetic slices in the array.

Example:

Input: [1, 2, 3, 4], Output: 3 (three arithmetic slices: [1, 2, 3], [2, 3, 4], [1, 2, 3, 4])
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 16

Maximal Square

Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.

Example:

Matrix: [[1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0]], Output: 4
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 17

Paint House

There are a row of n houses, each house can be painted with one of the three colors: red, blue, or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.

Example:

Costs: [[17, 2, 17], [16, 16, 5], [14, 3, 19]], Output: 10 (paint the first house blue, the second house green, and the third house blue)
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 18

Number of Dice Rolls With Target Sum

You have d dice, and each die has f faces numbered 1 to f. Return the number of possible ways (out of f^d total ways) to roll the dice so the sum of the face-up numbers equals target.

Example:

d = 2, f = 6, target = 7, Output: 6 (possible rolls: [1,6], [2,5], [3,4], [4,3], [5,2], [6,1])
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments

Most helpful rated by users:

Copyright © 2026, WithoutBook.