Maximum Subarray Sum Excluding Certain Elements

Problem Statement We are given an array, and we need to find maximum subarray sum excluding certain elements. That is, we need to find the max sum of subarray such that the subarray we are considering does not contain the elements which are told to be excluded. Example of maximum …

Read more

A Space Optimized DP solution for 0-1 Knapsack Problem

Problem Statement We are given a knapsack which can hold some weight, we need to pick some of the items out of given items with some value. The items should be picked such that the value of the knapsack ( total value of picked up items ) should be maximized. …

Read more

Printing brackets in Matrix Chain Multiplication Problem

Problem Statement We need to find the order of multiplication of matrices such that the number of operations involved in the multiplication of all the matrices is minimized. Then we need to print this order i.e. printing brackets in matrix chain multiplication problem. Consider you have 3 matrices A, B, …

Read more

Group Words With Same Set of Characters

In Group words with same set of characters problem, we have given a list of words with lower cases. Implement a function to find all Words that have the same unique character set. Example Input Words[]={ “may”, “student”, “students”, “dog”,”studentssess”, “god”, “cat”, “act”,”tab”, “bat”, “flow”, “wolf”, “lambs”,”amy”, “yam”, “balms”, “looped”, …

Read more

Decode Ways

In Decode Ways problem we have given a non-empty string containing only digits, determine the total number of ways to decode it using the following mapping: ‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Example S = “123” Number of ways to decode this string is 3 If we …

Read more

Maximum Subarray

In the Maximum Subarray problem we have given an integer array nums, find the contiguous sub array which has the largest sum and print the maximum sum subarray value. Example Input nums[] = {-2, 1, -3, 4, -1, 2, 1, -5, 4} Output 6 Algorithm The goal is to find …

Read more

Translate »