All Questions
Tagged with dynamic-programming array
13 questions
1
vote
3
answers
133
views
Another ATMs cash-out (denomination) algorithm in Java
Related to this question and this answer, I would like to have a second review from you on a modified version.
The problem I tried to solve
Some kind of "Minimum count of numbers required from ...
2
votes
1
answer
472
views
make html table in sync with javascript array
I have an array of users containing user name with their rules on my practice project
I have generated a table in HTML from that array in JS, So I can
change the ...
3
votes
1
answer
848
views
Divide array into three disjoint sets with equal sum
Problem definition : Array partition problem
Given an array of positive integers, divide it into three disjoint subsets having equal sum. These disjoint sets cover the complete array.
Example
Input: [...
3
votes
1
answer
122
views
Haskell implementation of Needleman-Wunsch
The code below is a Haskell implementation of Needleman-Wunsch algorithm for sequence alignment (and string edit distance). It's an experiment in trying to closely imitate the dynamic programming ...
3
votes
1
answer
4k
views
Count the number of distinct subarrays
I want to determine the number of distinct subarrays that can form having at most a given number of odd elements. Two subarrays are distinct if they differ at even one position. The subarray is a ...
1
vote
1
answer
1k
views
Odd Even Subarrays
I've been trying to understand Dynamic Programming lately, here's the question I just attempted:
You are given an array A of N positive integer values. A subarray of this array is called an Odd-Even ...
3
votes
3
answers
2k
views
Tower Hopper problem recursive approach
The Tower Hopper problem gives us an array of values representing heights that express how far we can jump from a certain tower, and asks whether there's a way to get from ...
3
votes
1
answer
442
views
Find the maximum possible summation of differences of consecutive elements
Array A contains the elements, \$A_1,A_2, \ldots, A_N\$.
And array B contains the elements, \$B_1,B_2, \ldots, B_N\$.
There is a relationship between \$A_i\$ and \$B_i\$: any element \$A_i\$ ...
1
vote
1
answer
113
views
Largest divisible subset optimization
So this is my solution to the following leetcode problem: https://leetcode.com/problems/largest-divisible-subset/description/
How could I optimize this code?
I think the run time is \$\mathcal{O}(n^2)...
3
votes
1
answer
2k
views
Finding the max product of a 2D array
Given a 2D array of unsigned integers and a maximum length n, find a path in that matrix that is not longer than n and which maximizes the product of the elements in the path. The output should ...
8
votes
5
answers
2k
views
Repeatedly partitioning an array equally as far as possible
I solved HackerRank Nikita and the Game. The implementation is correct as program passes all test cases.
Nikita just came up with a new array game. The rules are as follows:
Initially, ...
3
votes
3
answers
192
views
Max contiguous slice in Ruby
I need to compute the max contiguous slice in an array. I wrote this function, but I am not sure if it is correct or I am missing edge cases. I ran several cases.
...
4
votes
2
answers
6k
views
Finding all the subsets in an array of integers that sum to a given target
Problem Statement:
Given an Array if ints, Find out all the subsets in the Array that
sum to a given target value.
Example:
If the input array is:
...