Skip to main content

All Questions

5 votes
2 answers
176 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
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
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
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,585
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,585
8 votes
2 answers
458 views

(Codewars Kata) Memoised Log Cutting

(I am not sure of the official CS name for the problem in question, so I just gave it the name of the kata). Problem CLEAR CUTTER'S NEEDS YOUR HELP! The logging company Clear Cutter's makes ...
Tobi Alafin's user avatar
  • 1,792
3 votes
2 answers
4k views

"What is the fastest solution for finding the maximum sum of a subarray?"

Question Given an array, find the longest continuous sub-array which has maximum sum. My Approach First, I solved this problem using dynamic programming which effectively solved the problem in \$O(...
enigma6174's user avatar
3 votes
0 answers
791 views

Hackerrank: Sherlock and anagram (optimal time complexity)

Problem statement Given a string \$S\$, find the number of "unordered anagrammatic pairs" of substrings. Input Format First line contains \$T\$, the number of testcases. Each testcase ...
Jianmin Chen's user avatar
  • 2,426
4 votes
1 answer
3k views

Finding the longest path, avoiding obstacles in a 2D plane

The Scenario You are given a matrix of size m x n (width x height) with m*n spots where there are a few obstacles. Spots with obstacles are marked as 1, and those without are marked as 0. You can ...
GeT_RiGhT's user avatar
3 votes
1 answer
2k views

Calculate possible balances in piggy-bank by weight

I have solved Piggy-Bank problem on SPOJ using dynamic programming. The question asks you to get the minimum value that is possible with given weight (\$w\$) and one or more coins (\$n\$) with given ...
Hasil Sharma's user avatar
2 votes
2 answers
470 views

Calculating the number of prime numbers to solve the puzzle

How can the following program execution time improved? I have used dynamic programming in both "recursive" as well as "prime" function, but I'm not getting the efficient execution time. There is a ...
Torrtuga's user avatar
5 votes
2 answers
5k views

Optimizing O(m n) solution for longest common subsequence challenge

Given two strings string X of length x1 and string Y of length ...
swapedoc's user avatar
  • 457
11 votes
3 answers
1k views

Optimizing "Herd Sums" problem using dynamic programming

I'm trying to solve a practice problem and all is well except for the last 2 inputs my solution is too slow. Just one loop is slowing it down I think. Herd Sums Execution Time Limit: 2 seconds ...
jantristanmilan's user avatar