Skip to main content
Filter by
Sorted by
Tagged with
3 votes
1 answer
76 views

I'm working on a problem where I need to count, for each possible common difference D, the number of contiguous subarrays whose elements can be rearranged to form an arithmetic progression with common ...
YAR's user avatar
  • 31
2 votes
1 answer
188 views

I do not know when to use backward or forward computation for tabulation in solving a dynamic programming problem. I would like to know the thinking process to decide which one to use or which one ...
user avatar
0 votes
1 answer
106 views

I'm looking at one of the solutions to the programming problem: Partition a Set into Two Subsets of Equal Sum. The programming problem: Given an array arr[], the task is to check if it can be ...
charactersum's user avatar
9 votes
2 answers
263 views

A valid shuffle of two strings A and B is when their characters are mixed together to form a bigger string and all characters are used and the string is such that the order of characters in A and B is ...
Inclatable's user avatar
0 votes
1 answer
86 views

class Solution { public: int change(int amount, vector<int>& coins) { vector<unsigned int > dp(amount+1, 0); dp[0]=1; for (int value: coins){ ...
OXEN's user avatar
  • 13
6 votes
1 answer
174 views

Problem description: A mailbox manufacturer wants to test a new mailbox prototype's durability based on how many fire crackers it can withstand. Given k identical mailboxes (each holding up to m ...
Karma's user avatar
  • 77
0 votes
0 answers
52 views

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
3 votes
2 answers
121 views

Originally I faced a problem: I had three arrays of the same length (say, a, b, c), and I needed to choose indexes i, j, k distinct from each other that the sum a_i + b_j + c_k would be minimal. I ...
horart's user avatar
  • 73
2 votes
1 answer
156 views

It is a famous question which asked about finding longest nondecreasing subsequence from a given array. The question is well studied and have O(n log n) time complexity solutions. I have encountered a ...
tsh's user avatar
  • 4,838
2 votes
4 answers
230 views

Given a and b relating to a list of substrings in c: a = "how are you ?" b = "wie gehst's es dir?" c = [ ("how", "wie"), ("are", "gehst's&...
alvas's user avatar
  • 123k
-1 votes
1 answer
333 views

everyone! While I was solving the problems from cses.fi I came across the one that I totally couldn't understand. I searched the Internet and found the solution with DP along subsets, but still wasn't ...
Ivan_Striker's user avatar
3 votes
0 answers
53 views

A graph G(V,E) is defined by a set of vertices V and a set of edges E. Given W⊆V, find a connected subgraph G'(V',E') of G that satisfies the following conditions: i) ∀p∈V,∃p'∈V' such that p′ is ...
Sword fish's user avatar
0 votes
1 answer
105 views

Just by using the commented code instead of making the recursive calls inside the max function, leads to incorrect result particularly with the following test case int main() { Solution obj = ...
Mohamed Samir's user avatar
1 vote
2 answers
163 views

Problem: Given an array that sums to 0, find the maximum number of partitions of it such that all of them sum up to 0 individually. Example: input: [-2, 4, -3, 5, -4] output: 2 (which are [[5, -2, -3]...
figs_and_nuts's user avatar
1 vote
1 answer
110 views

Question: Given an undirected tree with N nodes ( 2 <= N <= 100,000 ) and N-1 edges, how can I find two non-intersecting paths with maximum product? Example: 6 1-2 2-3 2-4 5-4 6-4 Answer: 4 ...
Aibar's user avatar
  • 11
0 votes
1 answer
149 views

I was solving LeetCode problem 3290. Maximum Multiplication Score: You are given an integer array a of size 4 and another integer array b of size at least 4. You need to choose 4 indices i0, i1, i2, ...
souparno majumder's user avatar
2 votes
1 answer
49 views

I'm trying to simulate the level of a tank that has two inlet flows and one outlet. The idea is that after this will be used in a control problem. However, I can't get it to work with gekko but it did ...
iarima's user avatar
  • 45
-2 votes
1 answer
49 views

You are given an array containing n elements, where n is odd. In one operation, you can select an index i, such that 1 ≤ i < n and remove ai and ai+1 from the array and concatenate the remaining ...
20BCS029-Ishtiyak Ahmad Khan's user avatar
1 vote
1 answer
175 views

How can you find the maximum possible sum of values by optimally placing tiles in a matrix rxc where each cell has an integer value? The goal is to maximize the sum by covering cells with 1x2 or 2x1 ...
bigtree's user avatar
  • 13
4 votes
1 answer
279 views

A good follow up question asked in one of the interview post 'valid parentheses' problem. Given an imbalanced parentheses string, return the result string(any one of multiple solutions) with balanced ...
Shailendra's user avatar
0 votes
1 answer
58 views

class Solution { public: int countNeighborhoods(const vector<int>& houses) { int neighborhoods = 0; int m = houses.size(); for (int i = 0; i < m; i++) { ...
Shreshth Sharma's user avatar
0 votes
0 answers
73 views

Given an array of arrays, with each sub-array contains unique elements, but among different sub-arrays, there might be the same element. Select the top K sub-arrays, that the union of all elements ...
Shane's user avatar
  • 3
1 vote
1 answer
258 views

Here is a problem that was in a past exam for Advanced algorithms in my studies,it's on 5 points over 3 hours so should take approximately 1H but I am struggling to find the solution for the first ...
Solal Peiffer-Smadja's user avatar
0 votes
0 answers
19 views

I'm working on a dynamic programming problem related to counting the number of ways to partition an array into two subsets such that the absolute difference between their sums is equal to a given ...
Siddhant Jugran's user avatar
3 votes
3 answers
167 views

I'm struggling to write an algorithm for this problem. What approach can be used to solve it? Problem There's a company called CratePushers, whose employees are willing to push crates for money. Their ...
Zevgon's user avatar
  • 644

1
2 3 4 5
115