Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

2 votes
0 answers
48 views

Coin Change Recursive, memoization gone wrong

I'm trying to understand why first one fails and second works, all I'm doing is passing along coinTrack, call it redundant but why does it not work? It works without memoization, but on using ...
user2643191's user avatar
-2 votes
1 answer
115 views

Coin Change: for loop analysis

I am trying to comprehend the problem which has different wording but I figured it is similar to coin change problem Question: Two friends are playing a game with a book numbered from 1 to 9. The game ...
Lishant's user avatar
  • 43
0 votes
1 answer
143 views

What would be the most time efficient way to find the subsequences of length LIS? [duplicate]

Given an array(vector) sequence. I need a method or a fix possibly that will find all the increasing subsequences with the length of the longest increasing sequence. So for example: [1, 3, 2, 5, 2] ...
lukakone Konečnik's user avatar
0 votes
0 answers
98 views

Constructing result for given word's order and overlapping in Shortest Superstring Problem

For over 3 days I'm trying to solve Shortest Superstring problem and I still can't figure out how can I create resulting string when I know in what order should I use given words and how these words ...
Szyszka947's user avatar
-2 votes
1 answer
410 views

How to track path in Travelling Salesman Problem solved using DP and bitmasking

I wrote code to solve TSP (Travelling Salesman Problem) using DP, but I can't figure out how can I track the path that gives the solution. That's code: static int tsp(std::vector<std::vector<int&...
Szyszka947's user avatar
0 votes
1 answer
205 views

How to output the lexicographically smallest one shortest superstring?

The problem is : Given n strings si and find out the shortest string S so that every si is a substring in S. And output should be the lexicographically smallest one when there are multiple possible ...
user22847357's user avatar
0 votes
1 answer
130 views

Why does "Coin change" problem make no output in top down recursive function without Dp?

Top-down Recursive function to find minimum coin. #define INF 1000000 int coin[5] ={100,20,10,5,1}; int bill(int x) { if(x==0) return 0; if(x<0) return INF; int ...
Ex Nihilo's user avatar
0 votes
5 answers
339 views

Dynamic Fibonacci program

Not entirely sure if I implemented it correctly, but I tried to use memoization for this fib programme and it turns out to be slower than if I just ran it without, does anyone know why this is ...
kohtzerui's user avatar
0 votes
0 answers
262 views

Optimal Cost Calculation for String Construction with Append and Clone Operations in C++

Problem Overview: I'm working on a string construction challenge where I aim to build a target string from scratch. The process involves two primary operations: Appending any character to the current ...
Wayne's user avatar
  • 1
0 votes
0 answers
243 views

Ways to win a cricket match with 100% probability

In a recent contest this was one of the problems asked: Problem Statement: Pranay and Sumith are playing a cricket match. Sumith's team has scored X runs. Pranay's team has scored Y runs. There are 6 ...
Ultimate's user avatar
1 vote
0 answers
82 views

Time complexity increased by using memoization when I use map<pair<int,int>,int> to store the DP state

I was solving the CSES-Apple Division Problem. It was a dp sum difference minimization problem. We have to divide an array into two subsets whose sum difference is minimum. I was using basic Recursion ...
Red_RanGer's user avatar
6 votes
2 answers
448 views

Print sequence of tuples before returning a value for valid transactions

You are given a matrix V of dimensions m × n, where each element represents the prices of m different vegetables seeds for n consecutive days in a produce market. Furthermore, you are given an integer ...
WolfgangBagdanow's user avatar
-2 votes
1 answer
106 views

Bool condition checks gives warning

I am trying to solve a problem here https://leetcode.com/problems/word-break/ . My code looks like below:- bool existsInDict(string s, vector<string>& wordDict) { if(std::find(wordDict....
Invictus's user avatar
  • 4,246
4 votes
2 answers
205 views

Dynamic programming technique

I have this problem that I'm trying to solve: Given two numbers K and S, determine how many different values of X, Y, and Z exist such that 0 ≤ X, Y, Z ≤ K and X + Y + Z = S. Now, what I did is a ...
codeer's user avatar
  • 47
0 votes
1 answer
1k views

How to optimize recursive code to calculate beauty of an array?

You have an array of integers. You can delete as many elements as you can from the array and return the maximum beauty of the array. Beauty of the array is number of elements in the array which have ...
Nithya N's user avatar

15 30 50 per page
1
2 3 4 5
45