Category "recursion"

Understanding how this recursive method works [duplicate]

Can someone please explain how this method works? I tried adding System.out.print statements but it didn't get me anywhere and I simply cannot

ERD - Recursive relationship with two primary keys

I have a product table: Product (ID, Version) And I am having trouble creating a recursive table named "Update". this table should have a product ID and for eac

How to implement build in function .eval() with recursive function

Hei Coders, I have a string "1+1", with javascript build in function eval() i can do eval("1+1") so the return value will be 2 But how about if i want to imp

Recursion: Longest Palindrome Substring

This is a very common problem in which we would have to find the longest substring which is also a palindrome substring for the given input string. Now there ar

I tried to solve Best Sum problem in Python but I am not able to figure out the issue, please suggest what is wrong

The function should return an array containing the shortest combination of numbers that add up to exactly the target sum. If there are two (or more) possibiliti

Recursion - Python question, return value question

**I am having a problem with solving the question below. Implement the sum_positive_numbers function, as a recursive function that returns the sum of all positi

generating all permuated products from a map is not working

My code: #include <bits/stdc++.h> using namespace std; using ll = long long; vector<ll> generate_all(map<ll, int> mp, int keys

React: How to Animate Expanding and Collapsing Div When the Size of the Content is Not Knowable

Question: I have a React functional component that recursively renders nested lists. That part is working fine. The part that I am struggling with is getting t

PHP: set a (deep) array key from an array [closed]

is there a PHP function that would create a (deep) array key from an array ? It's quite difficult to explain, see that example: function myst

How to remove object properties with negative values, regardless of depth?

I'm looking for a way to remove object properties with negative values. Although an existing solution is provided here, it works only with no-depth objects. I'm

javascript merge sort and recursion

I am trying to understand how JavaScript merge sort function work. And I struggle understanding how the recursive function work. This is the code: const mergeSo

How to retrieve all posts of a user via Facebook Graph API using promises and recursion?

I am currently developing a web app which uses the Facebook Graph API. What I would like to achieve is to get all posts of a user. However, this is not that e

How do i make a recursive function in python which does the following? magic list

I've got an assignment in which I need to code a recursive function (with no loops) in python that returns: [[]] if n is 1 [[],[[]]] if n is 2 [[],[[]],[[],[[]]

Write a recursive method called which takes in an array of integers and returns said array in reversed sorted order

I have a programming exam in a few days so I'm doing some exercises just to practice. However, I've been stuck with this problem and I started to doubt if it's

print fibo big numbers in c++ or c language

I write this code for show fibonacci series using recursion.But It not show correctly for n>43 (ex: for n=100 show:-980107325). #include<stdio.h> #in

Multiply 2x2 Matrix in Python Recursively? No nested loops or numpy

I'm having a difficult time finding a very simple program that multiplies two 2x2 matrices recursively. Can anyone help me out? Just need to multiply X and Y wi

How to convert scala.some to scala.mutable.Map?

i am trying to write code to mask nested json fields.. def maskRecursively(map :mutable.Map[String,Object]):mutable.Map[String,Object] ={ val maskColumns = PII

'int' object is not subscriptable?

I'm doing an algorithm challenge on www.edabit.com, where you have a list of dice rolls, and: if the number is 6, the next number on the list is amplified by a

how to solve the recursion problem when specifying type hints for classes from different files

how to solve the recursion problem when specifying type hints for classes from different files models1.py from models2 import Second @dataclass class First:

given a list with integers separated by math symbols, find if a certain value can be calculated by placing braces

I'm trying to write a function which get: An integer. (s) A list with integers separated by math symbols.(L) By using recursion to determinate if the value of s