All Questions
51 questions
-1
votes
1
answer
129
views
Coin Change II : To take a value or not to
The problem goes like this:
You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.
Return the number of ...
-2
votes
2
answers
71
views
How to find the optimal products with the lowest price amount with the highest quantity?
I tried to write a function for myself but it somehow incorrectly outputs the final result:
function findOptimalProducts(products, budget) {
const getPrice = (priceString) => parseFloat(...
3
votes
1
answer
81
views
Return correct value at each iteration- dynamic programming
The problem goes like this:
Geek is going for n day training program. He can perform any one of these three activities Running, Fighting, and Learning Practice. Each activity has some point on each ...
0
votes
1
answer
182
views
Split Array problem. Need help in understanding another approach
I was solving this problem:
Given an integer array nums and an integer k, split nums into k non-empty subarrays such that the largest sum of any subarray is minimized.
Return the minimized largest sum ...
0
votes
2
answers
427
views
Find the minimal sum of the local maximum of the subarrays of an array
I need to write a function to calculate minimal sum of the local maximum of the subarrays of an array where every item is a positive integer with possible duplicates.
For example, we have an array [2, ...
0
votes
1
answer
82
views
How can I add proper memoization to optimize this recursive algorithm
I am looking at this leetcode question where I write a function that takes an array of numbers and output the biggest sum of non-contiguous sub-arrays.
For example, if the array is [1,2,3,1], the ...
0
votes
2
answers
783
views
How do I find the maximum path sum with path indication?
I have to find the maximum path sum starting from top right to bottom left of the matrix.
Therefore this is what I was asked to do:
Given an mxn grid filled with numbers, find a path from top left to
...
1
vote
1
answer
174
views
House Robber 2 Leetcode problem giving incorrect output
I am solving the Leetcode problem House Robber II. The problem says,
Given an integer array nums representing the amount of money of each house, return the maximum amount of money you can rob tonight ...
0
votes
1
answer
282
views
Weird Leetcode Bug: Array.fill() vs new Array.from() [duplicate]
I was working on Leetcode Problem 1770 and ran into some weird behavior that I'm hoping someone can help me understand.
It's a dynamic programming problem that requires you to instantiate a 2-...
0
votes
0
answers
46
views
maximum value that can be filled
I am trying to learn and practice data structure and I am practicing dynamic programming, and I am stuck over one problem. I don't know if it is my logical fallacy or anything.
my problem statement is:...
2
votes
2
answers
540
views
What am I missing in my approach to this Dynamic Programming problem? (Leetcode 740. Delete and Earn)
I'm trying to understand how to solve Leetcode Problem #740: Delete and Earn
I recently was given this problem as part of a pre-interview assessment and was unable to complete it in the allotted time. ...
0
votes
1
answer
164
views
How can I check string entirely is made up of defined substrings
Task
Here are some substrings: a, abb, aaaa.
How can I check that input string may be entirely made up of these substrings? I guess some algorithm from dynamic programming should be used here but I'm ...
1
vote
0
answers
233
views
Maximum Product In Matrix
I was trying to calculate the maximum product that can be achieved when traveling from the top left of a 2D array to the bottom right.
I know there is a solution here that uses dynamic programming in ...
1
vote
1
answer
81
views
How to fInd the index from which distance of every requirements are closest to the Index
let blocks = [
{
gym:false,
school:true,
store:false,
},
{
gym:true,
school:false,
store:false,
},
{
gym:true,// and this contains gym
school:true,
store:...
0
votes
1
answer
61
views
DP Solution Not Caching Properly - Time Out Error when input is ~70
I am trying to solve this problem: https://leetcode.com/problems/divisor-game/
My recursion itself seems to work but I get a time out error when the input is large enough ~ 70. I tried doing ...