python (12.9k questions)
javascript (9.2k questions)
reactjs (4.7k questions)
java (4.2k questions)
java (4.2k questions)
c# (3.5k questions)
c# (3.5k questions)
html (3.3k questions)
Subset sum variation, dynamic programming
I'm trying to do the classic subset sum problem with the caveat that the sum of the subset should get as close as possible to tgt without exceeding it. Here is my recurrence which finds how far away t...
BCBugajski
Votes: 0
Answers: 1
Recover solution from dynamic programming memo table
My goal is to find the longest sub-list of a list of numbers such that each element is at most 1 away from each other, e.g., a list of [0,1,2,2,3,3] from the list [0,4,1,2,2,3,3,1]. I create the memo ...
BCBugajski
Votes: 0
Answers: 0
count the ways to reach nth step using step 1,2 and 3 but take step 3 only k times
I am able solve this problem using recursion. Here is the code
int countstep(int n,int k){
if(n<0)
return 0;
if(n==0)
return 1;
int total_step=countstep(n-1,k)+countstep...
BRUCE
Votes: 0
Answers: 1
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 ...
h_a
Votes: 0
Answers: 1