All Questions
17 questions
3
votes
1
answer
3k
views
Recursive solution of ordered Coin Combinations II (CSES)
Question Link
Consider a money system consisting of n coins. Each coin has a positive integer value. Your task is to calculate the number of distinct ordered ways you can produce a money sum x using ...
1
vote
2
answers
343
views
Leetcode 377. Combination Sum IV Javascript Memoization attempt
Problem Statement
...
3
votes
0
answers
135
views
C++ - Longest Common Subsequence
Link to the Problem
Here is my code to compute the length of the longest common subsequence of two integer arrays arr[] and brr[]...
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 ...
2
votes
1
answer
168
views
How do I optimize memoization in order to find longest palindromic substring?
I want to find the longest palindromic substring using dynamic programming in Python3. The strings can be as large as this string.
I have seen other questions on this problem that successfully solve ...
1
vote
1
answer
636
views
CodeChef Matches challenge
I am solving some problems from CodeChef but I am stuck on the Matches problem:
Ari and Rich are playing a pretty confusing game. Here are the rules
of the game:
The game is played with ...
2
votes
1
answer
795
views
Given a string and a word dict, find all possible sentences
I have been trying to figure out how to meet space and time complexity requirements for the following leet code question. I have come up with two versions, one that meets the time requirements and ...
-2
votes
1
answer
1k
views
Dynamic Programming solution for one pile nim game
I have solved the following problem using dynamic programming: Little Deepu and his Girlfriend 1. To paraphrase,
We have two players Little Deepu and Kate and M items in the bag B,
also we have a ...
3
votes
3
answers
344
views
SPOJ Emoticon challenge
I tried this spoj problem and solved it using Dynamic Programming, but I was getting Time Limit Exceeded. The challenge is to count the number of occurrences of the subsequence "KEK" in each input ...
3
votes
1
answer
929
views
SPOJ - Alphacode, using dynamic programming
I am currently trying out a programming problem, SPOJ Alphacode, that involves dynamic programming. In an encoding system where A=1, B=2, …, Z=26, a message 25114 ...
5
votes
1
answer
1k
views
Hackerrank "Bricks Game"
Problem URL
This is the solution I came up with the minimax problem stated above. I did a top-down recursive approach with memoization, and I think this should be \$O(n)\$, since we are filling out a ...
1
vote
3
answers
1k
views
Code for calculating best possible combination in an array
The problem here , requires me to find the best possible combination of values in an array which is nearest to 0 and are adjacent to each other , here is an little excerpt from it,
The government of ...
5
votes
2
answers
704
views
Number of ways to make change for an amount
Task
Write a program that, given the amount to make change for and a list of coins prints out how many different ways you can make change from the coins to STDOUT.
My approach
The number to make ...
6
votes
1
answer
121
views
Optimal way to annihilate a list by removing items from the ends
I'm stuck with a contest problem.
Description:
What is the minimum number of moves to annihilate an int array where the possible moves are:
Remove both the first and last elements if they are equal ...
4
votes
1
answer
946
views
Optimizing a dynamic programming solution for "Oil Well"
I'm trying to solve the Oil Well problem on Hackerrank using dynamic programming and it works. However, it times out for some of the test cases. I wanted to know how this program can be improved so ...