Skip to main content

All Questions

5 votes
2 answers
173 views

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 ...
user430243's user avatar
4 votes
1 answer
117 views

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 ...
ayaan098's user avatar
1 vote
1 answer
106 views

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 ...
Lesserrafim's user avatar
6 votes
1 answer
347 views

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 (...
user24714692's user avatar
2 votes
1 answer
96 views

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-...
Jianrong Li's user avatar
0 votes
1 answer
374 views

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 ...
Eren Yeager's user avatar
3 votes
2 answers
362 views

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 ...
xrfxlp's user avatar
  • 191
2 votes
1 answer
81 views

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 ...
Rajdeep Paul's user avatar
2 votes
1 answer
191 views

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/...
Gilad's user avatar
  • 5,293
7 votes
1 answer
1k views

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 ...
Sai Dutt's user avatar
  • 121
5 votes
1 answer
351 views

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 ...
nz_21's user avatar
  • 1,051
4 votes
1 answer
633 views

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 ...
Justin's user avatar
  • 2,575
2 votes
0 answers
377 views

Bursting Balloons

This is a Leetcode problem - Given n balloons, indexed from 0 to n-1. Each balloon is ...
Justin's user avatar
  • 2,575
-1 votes
1 answer
908 views

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 <...
Justin's user avatar
  • 2,575
3 votes
1 answer
2k views

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 ...
Justin's user avatar
  • 2,575

15 30 50 per page