All Questions
4,351
questions
-3
votes
1
answer
77
views
Create a recursion function to respond with a different object [closed]
I'm a receiving the following data from a HTTP request to get all menus available:
[
{
"ID": "2",
"Name": "Home",
"ParentID": "1&...
0
votes
3
answers
70
views
difficulty to understand the code, and maybe the concept itself (recursion problem)
this code below is from Grokking Algorithms book that is an exercise for the functional programming/recursion and an application for the D&C concept. the function finds the maximum number in a ...
-4
votes
3
answers
106
views
algorithm using recursive function
https://codeup.kr/problem.php?id=6098
Hi, Dear!
I ask your precious advice..
Thank you in advice
[Rule : Problem Statement]
start point : (1,1)
Only move to 0
Must move right(0,1) or down(1,0)
(* ...
0
votes
0
answers
47
views
What will be the recurrence relation of method which finds the sum of array elements?
public static int sumRecursive(int[] arr, int i) {
if (i == arr.length) {
return 0;
}
return arr[i] + sumRecursive(arr, ++i);
}
F(i) = arr\[i\] + F(i + 1)
or
F(arr, i) = arr\[i\] +...
3
votes
1
answer
138
views
Problems with recursive functions
I have recently challenged myself to write the Depth First Search algorithm for maze generation and am on the home stretch of completing it but I have been battling a specific error for most of the ...
0
votes
1
answer
61
views
Understanding the Time Complexity Difference of Two Ways to Generate Subsets
I was recently performing a complexity analysis on two separate methods for generating the subsets of a given set. For this question, I am removing all unessential components of the code, meaning that ...
0
votes
2
answers
109
views
Dynamic Programming - Minimum cost to fill given weight in a bag
We are given an array of positive weights cost where cost[i] represents the cost of filling i + 1 kg's of oranges in a bag (0-based indexing). We need to find the minimum cost to buy exactly w kg's of ...
-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 ...
3
votes
1
answer
67
views
Return correct value at each iteration- dynamic programming
The problem goes like this:
Geek is going for n day training program. He can perform any one of these three activities Running, Fighting, and Learning Practice. Each activity has some point on each ...
1
vote
1
answer
40
views
133. Clone Graph: Node with value 2 doesn't exist in the original graph
I get a similar error with a different root cause compared to: Clone Graph LeetCode 133
Consider the below implementation. If I use a Node-type key for processed_node_map, the algorithm passes. If I ...
-3
votes
1
answer
88
views
Calculate Win/Lose/Draw probability If I stand with given hand in BlackJack [closed]
I am trying to solve a code challenge. It is about the game blackjack. 2 cards are given to me, 1 to the dealer. I know every card including the deck. I need to calculate the probability to win, to ...
1
vote
1
answer
61
views
Algorithm for compound fractions
I have a set of N chemical compounds enumerated 1, 2,..., N. For each compound, I have the fraction of each of its constituents, "A", "B", and so on. Compounds can also contain ...
0
votes
1
answer
73
views
Recursive implementation of N-Queen
N-Queen Problem is one of the first problems taught in the Computer Science Branch when we go through the chapter of Recursion. This problem is studied well in Maths and CS.
I coded the problem in a ...
2
votes
1
answer
76
views
Recursive backtracking - Word search in a 2D array
I was attempting the word search problem here on leetcode. Leetcode seems to give me an error for the two test cases:
board = [["a","a"]], word = "aa"
and for : board = [[...
2
votes
3
answers
207
views
Maximum Sum Without Skipping Two Contiguous Elements
The task is to find the maximum sum of a subsequence of integers from a given list. The subsequence must follow two conditions:
It must be contiguous, meaning the selected elements are in consecutive ...