All Questions
15 questions
5
votes
3
answers
962
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 ...
3
votes
2
answers
2k
views
LeetCode: Longest String Chain (Java)
For the question, I had a pretty messy solution so I would like some advice on how to better use Java to make the code a bit cleaner.
Also, a semi-hack that I did that I'm not proud of is checking if ...
5
votes
2
answers
124
views
Calculate the rates at which users get stuck at each stage
I completed an algorithm problem just as a personal study, and I can't help but feel like my solution is a bit needlessly complicated, although I can't figure out a better way to do it. Here's the ...
3
votes
2
answers
833
views
Optimal burger-eating challenge
Little history to give context to the problem:
The Krusty-Burgers
Homer Simpson is a smart guy who likes to eat Krusty-Burgers, and it takes m minutes for Homer ...
0
votes
2
answers
506
views
Making Anagram Problem Implementation
Problem Statement
Alice is taking a cryptography class and finding anagrams to be very useful. We consider two strings to be anagrams of each other if the first string's letters can be rearranged to ...
3
votes
1
answer
10k
views
Solving maze problem with backtracking solution using stack
I solved the maze backtracking question using a stack however could not find any other solution like that anywhere (to validate my solution is actually a valid one).
The problem statement is as ...
3
votes
2
answers
4k
views
"What is the fastest solution for finding the maximum sum of a subarray?"
Question
Given an array, find the longest continuous sub-array which has maximum sum.
My Approach
First, I solved this problem using dynamic programming which effectively solved the problem in \$O(...
0
votes
1
answer
303
views
Count number of ways to achieve a sum [closed]
The Question :
Utkarsh being a very talkative child, was scolded by his teacher
multiple times. One day, the teacher became very angry and decided to
give him a very rigorous punishment. He made ...
4
votes
1
answer
274
views
Assembly Line Scheduling challenge, solved using TDD
I am new to Test Driven Development and currently practicing it with some problem statement. Following is an Assembly Line Problem statement I solved using TDD approach in java. Please provide me some ...
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, ...
12
votes
2
answers
640
views
Dynamic Programming: Fibonacci-like recurrence relation
This is a problem from my Introduction to Algorithms textbook.
Consider the infinite sequence of numbers An|n>0 = (1,1,3,4,8,11,...) defined recursively as follows.
$$
A_n = \left\{\begin{aligned}
&...
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:
...
10
votes
1
answer
4k
views
Project Euler #14 -- longest Collatz sequence
I was reading this question and realized that I didn't know Python well enough to critique the algorithm. So I wrote a Java solution instead, which is inappropriate for that question. Since there's ...
2
votes
2
answers
470
views
Calculating the number of prime numbers to solve the puzzle
How can the following program execution time improved? I have used dynamic programming in both "recursive" as well as "prime" function, but I'm not getting the efficient execution time.
There is a ...
11
votes
3
answers
1k
views
Optimizing "Herd Sums" problem using dynamic programming
I'm trying to solve a practice problem and all is well except for the last 2 inputs my solution is too slow. Just one loop is slowing it down I think.
Herd Sums
Execution Time Limit: 2 seconds
...