Skip to main content
The 2025 Developer Survey results are in. Explore insights into technology and tools, careers, community and more. View results.

All Questions

Filter by
Sorted by
Tagged with
1 vote
1 answer
63 views

Depth-first traversal implementation in Java (by recursion)

I implemented a recursive depth-first traversal, with all three traversal modes in this function. Is this the most succinct way to write the code? ...
fidgetyphi's user avatar
7 votes
1 answer
1k views

Recursive parser from Binary to JSON output

Background I got this interview test and got declined due to not meeting their expectations, but never got a reason on what was bad and how they solved it. I want to improve and learn something out ...
Rovdjuret's user avatar
  • 173
1 vote
1 answer
336 views

Rearrange an array in place such that the first and last halves are interleaved

Given an array of n elements in the following format { a1, a2, a3, a4, ….., an/2, b1, b2, b3, b4, …., bn/2 }. The task is shuffle the array to {a1, b1, a2, b2, a3, b3, ……, an/2, bn/2 } without ...
Anirudh Thatipelli's user avatar
1 vote
2 answers
772 views

Find all root to leaf paths in binary tree

Description: Given a binary tree, return all root-to-leaf paths. Leetcode ...
CodeYogi's user avatar
  • 5,177
2 votes
1 answer
524 views

Find minimum depth in a binary tree

Description: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a node ...
CodeYogi's user avatar
  • 5,177
0 votes
2 answers
972 views

Number of Paths (BackTracking) in Java

Illustration You're testing a new driverless car that is located at the Southwest (bottom-left) corner of an n×n grid. The car is supposed to get to the opposite, Northeast (top-right), corner ...
Anirudh Thatipelli's user avatar
2 votes
2 answers
6k views

Find the minimum number of coin change

Description: You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that ...
CodeYogi's user avatar
  • 5,177
2 votes
1 answer
2k views

Regular Expression Matching: Recursive and DP-based implementation

Problem Statement: Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching ...
mycleanlittlescrete's user avatar
3 votes
4 answers
12k views

Multiplying 2 numbers without using * operator in Java

I saw this interview question and decided to solve using recursion in Java. Write a multiply function that multiples 2 integers without using * ...
user avatar
4 votes
3 answers
5k views

Reversing strings using recursion

I'm trying to solve exercises where I am required to use recursion. I wrote this: ...
Pulkownik's user avatar
  • 317
5 votes
2 answers
2k views

Non-recursive method for finding \$a^n\$

I am working on an interview question from Amazon Software. The particular question I am working on is "to write a program to find \$a^n\$." Here is my recursive solution to this problem (in Java): <...
committedandroider's user avatar
5 votes
1 answer
20k views

Print all possible combinations of size r, from an array of size n

This is my working solution for the following problem: given an array of integers of size n, print all possible combinations of size r. Before I proceed to the solution, I have the following question:...
user3371223's user avatar
11 votes
3 answers
24k views

Recursive, nested list traversal

Given a nested list of strings (which may contain other nested lists), print the contents of the list and the corresponding depth. Here is my solution: ...
user3371223's user avatar
12 votes
3 answers
17k views

List all possible numbers from a given array that sums up to a given number

I have to solve the following problem: Given an array of integers and given an integer value, list all possible numbers frm the array that sums up to the given value. Example: Input: array = {1, 2, ...
user3371223's user avatar