5,714 questions
0
votes
0
answers
55
views
Time Complexity Analysis for a Plant Positioning Algorithm
Please verify my understanding, but I believe the time complexity of this solution can be described as O(row * column * column) due to the presence of Math.min() and array.slice() operations within a ...
2
votes
1
answer
148
views
GEKKO / IPOPT - NL Optimization becomes unfeasible because of a change in exponent
I am attempting to run a dynamic optimization model in discrete time with GEKKO and IPOPT (v3.10.2). My model is the following :
from gekko import GEKKO
import numpy as np
# Simulation time
T = 5 ...
0
votes
1
answer
59
views
Is it possible in Angular 13 to deploy build in different domain having different apiURL without rebuilding the application?
I am working on a functionality in which i will make a build for DEV environment and deploy on DEV domain . Further , without rebuilding the application again for QC environment , i want to make use ...
0
votes
1
answer
108
views
dungeon problem using dp recursive approach
This is the Question...
The following problems revolve around an adventurer who enters a dungeon in search of Gold
(Treasure). The objective for all the questions will be to find the quickest path to ...
6
votes
2
answers
456
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 ...
2
votes
1
answer
2k
views
Number of ways to color houses with no 2 equal colors next to each other and symmetry constraint
There are n houses along the street, and we need to color every with one of 3 colors but there are 2 constraints:
Adjacent houses need to have different colors
Symmetric houses cannot have the same ...
3
votes
4
answers
4k
views
Given an array of N integers, return the max sum of 3 NON-adjacent elements
I got this question for a coding interview (mock, part of my uni's competitive programming club since a few people are curious lol), and I got stuck on finding the optimal solution. Extra details/...
0
votes
1
answer
124
views
Error in Making Change using Dynamic Programming in c
Well i have tried it many time and still unable to find the error in the code below it is making change proble using dynamic programming need help to eliminate the wrong output and if possible plz ...
1
vote
1
answer
142
views
Getting Run Time error for a Kattis Problem(robotsonagrid)
I am trying to solve this problem (https://open.kattis.com/problems/robotsonagrid).
And when I submit my final code I keep getting a Run Time error in Test case 4. I am not sure what's wrong with my ...
4
votes
1
answer
504
views
Maximum Profit for selling/buying stocks but we can only have absolute value of at most k shares
I have a classic interview problem to ask but it is with a twist:
You are given the stock prices for n days, a1, a2, ..., an. You are also given an integer 1 <= k <= n. Each day, you can do one ...
1
vote
0
answers
132
views
How to find least number of moves to swap adjacent colored tiles on 2D grid so that no colors are adjacent?
Sam recently hired a tile installer to tile a kitchen floor. The floor was supposed to be very colorful with no two adjacent tiles having the same color. Unfortunately, the installer failed to ensure ...
-1
votes
1
answer
421
views
"Coin change 2": Why is this dynamic programming implementation not efficient enough? [closed]
I am working on a LeetCode problem, 518. Coin Change II:
You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.
...
-1
votes
1
answer
87
views
Adding memorization (dp) to my recursive code gives different result which is wrong
I have been stuck on this LeetCode problem Number of increasing paths in a grid:
You are given an m x n integer matrix grid, where you can move from a cell to any adjacent cell in all 4 directions.
...
1
vote
0
answers
22
views
Inconsistent output on leetcode and vs code [duplicate]
class Solution:
def combinationSum4(self, nums: List[int], target: int,memo={}) -> int:
if target in memo:
return memo[target]
if target==0:
return 1
...
1
vote
1
answer
163
views
Delphi function SetProperty (ComponentName: string, PropertyName: string, JSONValue: string): boolean;
How would I go about to write a function that takes the name of a component and property and a JSON value string and populate that component's property with the value dynamically?
The property can be ...
0
votes
1
answer
130
views
Ideal Profits in companies in Perfect Binary Search tree
I'm trying to solve the following problems here:
In the X world, companies have a hierarchical structure to form a large binary tree network (can be assumed to be a perfect binary tree). Thus every ...
1
vote
3
answers
83
views
Every Potential Combination of a Number from a List
I'm attempting to generate all conceivable combinations of a given number using elements from a list. For instance, when the number is 4 and the list contains [1, 2], there are 3 possible combinations:...
0
votes
2
answers
157
views
Optimization of matrix search
I have a matrix of 6 columns and 375 rows, the user sets any number. The task is as follows, find all combinations in which a number is taken from each column (a total of 6 numbers) and their sum ...
0
votes
0
answers
42
views
I was trying to solve this question on GFG. Can anyone please tell me what is wrong with my code?
Geek's Journey
You're provided with two arrays:
"geeksTown" of length n - representing the heights of buildings in
Geek's town "journey" of length m - representing the ...
1
vote
0
answers
52
views
How can I write the output stream of sddp.jl into an excel file?
I am using sddp.jl for my research project in which I am developing a state-of-the-art actor critic algorithm which I am going to benchmark with SDDP but for it I need to plot graphs which require ...
-1
votes
1
answer
140
views
Finding the Maximum and Minimum Number of Operations to Delete all Element in a Circular List
In a circular list of length n, where a1 is adjacent to a2, a2 is adjacent to a3, and an is adjacent to a1. Each operation can delete one number, after each deletion, if there exists adjacent equal ...
0
votes
1
answer
72
views
Boolean Parenthesization Problem's code is not working
Regarding the "Boolean Parenthesization" problem, my code doesn't work. I tried the approach using the dynamic approach, however for the the input of N=5 and T^F|F, I got 0 as the output but ...
1
vote
1
answer
194
views
Why does my solution not work for coin change problem?
At every recursive call I choose 1 more of current denomination or no more of current denomination. I sort the denominations in descending order and use a cache of seen remaining amount. Since I try ...
6
votes
1
answer
413
views
Is there any true general pattern to solve any dynamic programming problems?
I understand there is a general pattern to solve dynamic programming problems. Consists of:
Identify Overlapping Subproblem by Breaking down the problem into smaller subproblems that are solved ...
3
votes
1
answer
1k
views
Find the maximum sum of all contiguous subarrays and not consecutive each others which its length at most 'k' in a given array
Problem: Given an array 'arr' and an integer 'k', find the maximum sum of all subarrays of 'arr' whose size is at most 'k'. Note that you can't choose subarrays which are consecutive or overlap each ...
0
votes
0
answers
29
views
Solution works in Code Editor but not in LeetCode [duplicate]
I'm currently doing the "Word Break" problem in LeetCode. It is a dynamic programming problem with the difficulty "Medium". For some extrange reason, the exact code (but without ...
-4
votes
1
answer
228
views
Why this shortest pathfinding algorithm not working?
Trying to find the shortest path through a dynamic programming approach
but it doesn't seem to be working below is the code of the algorithm and the graph class.
I tired to store the paths through a ...
-1
votes
1
answer
57
views
Why --i and i-1 producing diffrent output in recursion?
I have two method, the difference is one is having --i1 and other is having i-1, however they are producing different output.
String s1 = "axbdcg";
String s2 ="...
0
votes
1
answer
26
views
GridTraveler tabulation error making all elements of the table 0 in js
this is the tabulated version of gridTraveler, where you output the number of ways one can travel from the top left to the bottom right corner in an m*n box, but you can only move down or right.
const ...
0
votes
1
answer
979
views
API in Dynamics AX 2012
I have a problem in AX 2012 when I call API by Https URL give me this error
(The request was aborted: Could not create SSL/TLS secure channel)
but when I test code in Dynamic 365 It Work
This My code:
...
2
votes
0
answers
269
views
minimum number of operations to get a target number
If there is a list of digits in string format, e.g. ["1", "5", "8"], list of valid operations are "+","-", and "*" and a target number. Find ...
4
votes
2
answers
143
views
Count ways to reach end from start stone and come back, without taking using the same stone twice with at most K jumps at each step
Richard is a penguin who regularly commutes between Canada and the United States.
Specifically, Canada is at location 1
, and the United States is at location N.
In locations 2 through N, there are ...
-1
votes
1
answer
25
views
Given an array of integers, how can I assign the ints to two different arrays that have a capacity?
You're given a list of integers, you must add the integers to one of two lists, each of these lists has the same capacity that the sum of ints inside the list must be under.
This is just a rough ...
0
votes
1
answer
180
views
Max Sum in array excluding adjacent numbers
maximum sum of an integer array such that if we consider an element a[i] then we should not consider a[i]-1 and a[i]+1. for example if array a = [1,1,1,1,1,2,2] the o/p = 5 and if a = [3,3,3,4,4,8,1] ...
0
votes
1
answer
57
views
Python acting in a strange way (Dynamic Programing) [duplicate]
I have written this following code that takes an integer N and and array of integers: arr. The task is to find the shortest combination of the integers in arr that sum up to N . Each elements of arr ...
0
votes
1
answer
1k
views
in gdscript how do you get the toggled function to do something when a checkbox is clicked in the godot engine
in gdscript (using godot 4.1.1 stable) i am working on a function that adds a checkbox dynamically works fine
but when i try to get it to do something when it is toggled i get all sorts of errors this ...
-2
votes
1
answer
222
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....
0
votes
0
answers
263
views
Counting Subproblems in Dynamic Programming?
Taking a class on algorithms - trying to understand what is meant by the 'count of a subproblem' when discussing dynamic programming.
The scenario I'm faced with is as such:
An investor wants to ...
0
votes
1
answer
414
views
Printing minimum path sum path (matrix)
Solving [leetcode problem][1] which is as follow:
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.
...
0
votes
1
answer
143
views
Finding the subset of a dictionary that has the minimum edit distance to a given string
I'm looking for the most efficient way of solving an Levenshtein edit distance problem.
We are given as input:
A set of strings S of size n <= 8, with average length m <= 50
A target string t of ...
0
votes
1
answer
59
views
while doing subset sum whose sum equals to B i am not able to get correct result
the code is very simple i am taking or not taking an element from A array and using left i am keeping track left sum it is interview bit problem
Subset Sum Problem!
class Solution:
def solve(self,...
1
vote
4
answers
344
views
I want to find a formula to find the mode of the highlighted cells in excel
I am trying to find a formula to find the mode of the highlighted cells. The value inside cell D13 will determine the number of highlighted cells. If it is 3, 3 rows will be highlighted starting from ...
2
votes
1
answer
835
views
Proof of dynamic programming solution for Leetcode 818: Racecar
The problem is as follows:
Problem:
"Your car starts at position 0 and speed +1 on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a ...
4
votes
2
answers
229
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 ...
0
votes
0
answers
131
views
How to find out phonenumbers based on (chess) knight moves
So basically in this problem we have a knight (from chess) and a keypad from a phone. Using the possible moves for knight (i.e. 'L' shape) we have to find the total count of phone numbers that can ...
0
votes
2
answers
106
views
What's the difference between these two code fragments?
I'm working on this Leetcode question. I cannot figure out the difference between my commented and uncommented code below. I'm returning an array at the base-case of a recursion, so when I call the dp(...
0
votes
1
answer
211
views
Construct the different possible ways to reach a target string from a list of words
The code is supposed to produce a two dimensional list of all the possible ways a target can be reached from a list of word bank but the actual output confuses me. Is there a better way to tackle this ...
0
votes
2
answers
3k
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 ...
1
vote
1
answer
1k
views
Find the number of simple paths from A to B going through a given point on the graph
I am looking into an interesting issue in networks.
Given an undirected graph which can contain cycles:
I choose two points, A and B as origin and end of my paths. My goal is to calculate how many ...
0
votes
1
answer
201
views
Difference Between Two Strings question in c++
Diff Between Two Strings
Given two strings of uppercase letters source and target, list (in string form) a sequence of edits to convert from source to target that uses the least edits possible.
For ...