All Questions
13 questions
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-...
2
votes
1
answer
127
views
Coin partitions
I am looking to obtain the partitions of coins that sum to a target amount
So I tried search online, but every single website loves to use this problem to show the benefits of dynamic programming. ...
2
votes
1
answer
128
views
Find ALL duplicate subtrees. using recursion
This is just a practice exercise, I'm trying to understand dynamic programming as deeply as I can. I solved this using recursion, though I am not sure if it will always work. If anyone could tell me a ...
3
votes
1
answer
231
views
Killing a Hydra - Overengineered
Background
This question is inspired by the question: Killing a hydra, and my response therein. I will restate the problem at hand in full so that this question is fully self contained
You can only ...
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 ...
1
vote
1
answer
462
views
Maximum sub array sum equal to k
Given an array of integers and an integer k, you need to find the
total number of continuous subarrays whose sum equals to k.
For example:
Input: nums = [1,1,1], k = 2
Output: 2
...
2
votes
1
answer
103
views
dynamic programming solution for a string ending with 0, 1 or 2
A string that contains only 0s, 1s, and 2s is called a ternary string. Find a total ternary ...
1
vote
1
answer
843
views
Compute the number of ways a given amount (cents) can be changed
Given an infinite number of different coin types (such as pennies,
nickels, dimes, quarters) find out how many ways n cents can be
represented.
My code appears to work (although I am curious to ...
7
votes
2
answers
713
views
Recursive function and memorization to find minimum operations to transform n to 1
I'm a new, self-taught programmer working on the Google FooBar challenge. I've submitted my answer (code at bottom) and it was accepted, but I'd like suggestions on how to improve my solution.
...
6
votes
1
answer
3k
views
Longest common subsequence length and backtracking the string
Problem: Given two sequences, print the longest subsequence present in both of them. A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous. For example, “...
3
votes
1
answer
386
views
Number of unique sequences of 3 digits, given a length is equal to sum
This is the "Minion's bored game" problem from Google's "Foobar challenge":
There you have it. Yet another pointless "bored" game created by the bored minions of Professor Boolean.
The game is ...
0
votes
2
answers
423
views
google foo.bar max path algorithm puzzle optimization [closed]
I got a programming puzzle described as follows:
Save Beta Rabbit
Oh no! The mad Professor Boolean has trapped Beta Rabbit in an NxN
grid of rooms. In the center of each room (except for the ...
2
votes
1
answer
230
views
Memoization for calculating minimal traversal distance within a positive matrix
The code below is for calculating the minimal traversing distance from the top left point of the matrix to the bottom right point of the matrix.
GitHub
Here is the core functionality. Please note ...