Skip to main content

All Questions

5 votes
3 answers
957 views

LeetCode 678: Valid Parenthesis String, Recursion memoization to DP

How can the following recursion + memoization code be converted into a tabulation format dynamic programming solution? The code is working, but I want to improve it. The challenge I am facing is ...
Elias El hachem's user avatar
4 votes
2 answers
131 views

Find largest sum not involving consecutive values

There is a question to basically find the largest sum in an array, such that no two elements are chosen adjacent to each other. The concept is to recursively calculate the sum, while considering and ...
BlazeRod11's user avatar
2 votes
1 answer
194 views

k-dice Ways to get a target value

I'm trying to solve the following problem: You have a k-dice. A k-dice is a dice which have k-faces and each face have value written from 1 to k. Eg. A 6-dice is the normal dice we use while playing ...
driver's user avatar
  • 222
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-...
Jianrong Li's user avatar
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. ...
N3buchadnezzar's user avatar
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 ...
beatmaister's user avatar
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 ...
N3buchadnezzar's user avatar
3 votes
1 answer
319 views

Efficiently calculate value of Pascal's Triangle using memoization and recursion

So reading about functional programming, applications to dynamic programming, and learning Scala. I figured I would try it out with a popular example, Pascal's Triangle, tests against known values ...
Martin Boros's user avatar
3 votes
0 answers
314 views

LeetCode: Stone Game C#

https://leetcode.com/problems/stone-game/ Alex and Lee play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones ...
Gilad's user avatar
  • 5,293
0 votes
1 answer
375 views

Generate unique string permutations recursively

🧩 Objective Write a recursive method for generating all permutations of an input string. Return them as a set. See: Recursive String Permutations - Interview Cake 🔎 Questions 1: How does the ...
adamhurwitz.eth's user avatar
1 vote
2 answers
247 views

Recursive brute-force approach to maximum points you can obtain from cards

I came across this question on Leetcode. The question description is as follows: There are several cards arranged in a row, and each card has an associated number of points. The points are given in ...
Jitesh Malipeddi's user avatar
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 ...
Sai Dutt's user avatar
  • 121
3 votes
2 answers
1k views

Counting the number of ways to decode a string

I am working on problem where I need to decode a string: A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... '...
user5447339's user avatar
2 votes
3 answers
908 views

Leetcode #91 - Number of ways to decode a string

I'm working on problem 91 on Leetcode.com called Decode Ways and I've successfully managed to get a working recursive solution but it results in Time Limited ...
springathing's user avatar
3 votes
2 answers
921 views

Memoized solution to Count number of ways to climb n steps

Problem statement : A Child is climbing up n steps with either 1 , 2, 3 hops ..how many ways can the child climb up the stairs? source: cracking the coding interview book. I have two solutions the ...
DntFrgtDSemiCln's user avatar

15 30 50 per page