All Questions
Tagged with dynamic-programmingperformance
40 questions
5votes
2answers
176views
LeetCode Number 416: Partition Equal Subset Sum
Problem: MLE I am confused as to why the LeetCode judge reports Memory Limit Exceeded when my solution looks close to the editorial solution. I not too familiar with ...
4votes
1answer
117views
Calculate optimal game upgrades, v2
This is the second iteration of the code I originally posted here: Calculate optimal game upgrades. Based on the feedback there, I chose to change the code to use a dynamic programming approach with ...
1vote
1answer
106views
Finding the number of distinct decompositions a number has using only repdigits
This is a problem from a previous semester that I am trying to upsolve. I am trying to solve a problem involving the total number of ways of decomposing a number using only repdigits. A repdigit is a ...
6votes
1answer
347views
Codeforces: D2. Counting Is Fun (Hard Version)
The code works okay for the following problem. Problem An array 𝑏 of 𝑚 non-negative integers is said to be good if all the elements of 𝑏 can be made equal to 0 using the following operation some (...
2votes
1answer
96views
Find all non-crossing tuples which has the same content with a given tableau
Let T be a semistandard Young tableau of rectangular shape. For example, [[1,2,4],[3,5,6]] is such a tableau, where [1,2,4] and [3,5,6] are columns. All non-...
0votes
1answer
374views
Grid Dynamic Programming
atcoder.jp Problem Statement: There is a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the ...
3votes
2answers
364views
Divide a set into subset with some constraints
Problem: Given a list L consisting of not necessarily unique non-negative integers, find the minimum number of subset with maximum sum ...
2votes
1answer
81views
Why below recursive DP solution is so slow? (Leetcode Q# 123 - Best Time to Buy and Sell Stock III)
This is regarding leetcode Question# 123. I have solved the question (code below) but the solution is showing "Your runtime beats 5.89 % of cpp submissions."? Is there any additional ...
2votes
1answer
191views
LeetCode: Trapping Rain Water DP C#
Please review for performance and C# style. I already solved this question in 1 way. LeetCode: trapping rain water C# I tried also the dynamic programming approch https://leetcode.com/problems/...
7votes
1answer
1kviews
Printing the number of ways a message can be decoded
My below solution to the following problem is exceeding the maximum recursion depth. I am looking for any improvements which i can make. Problem Alice and Bob need to send secret messages to each ...
5votes
1answer
351views
Total number of non overlapping subsets
I am trying to solve this question. The essence of the problem is this: Given a list of school classes with start and end times, find the total number of non-overlapping subsets. I've written up a ...
4votes
1answer
633views
The Dungeon game
This is a Leetcode problem - The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our ...
2votes
0answers
377views
Bursting Balloons
This is a Leetcode problem - Given n balloons, indexed from 0 to n-1. Each balloon is ...
-1votes
1answer
908views
Python program to solve the "rod-cutting problem"
An assignment at school required me to write a program for this task: In the rod-cutting problem, we are given a rod of length n inches and a table of prices <...
3votes
1answer
2kviews
Python program for "0-1 knapsack problem"
Here is what a knapsack/rucksack problem means (taken from Wikipedia): Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that ...