Recursion Interview Questions [2026-2027]

74+ real questions from verified interview reports across 12 companies.

Sourced from 1Point3Acres, Blind, Glassdoor, Reddit, and more. Translated and cleaned.

74
Questions
12
Companies
12
Top Askers

Top Companies Asking Recursion Questions

Sample Recursion Questions

Completed technical phone screen with Verily Life Sciences. Got asked this problem ## Question Given an arithmetic expression like `a-(b+c)` return a simplified expression. Examples: * `a-(b+c)` gives

Write a JSON parser that can parse strings, lists of strings, or lists of lists. Here are a few examples: "Hello World" ["Hello World"] ["abc", "def"] ["abc", ["aaa", "bbb"], "ccc"] You don't need to

Pattern : written + 2TECH + 1 HR(But for me 1Tech + 2HR)Type : OnlineCgpa criteria : NOWritten Exam Modules : 60 questions 70 min (no -ve marking) Aptitude questions were ...

This article will give you information about the company, its recruitment process, sample questions that have been asked previously, lots of experiences shared by other as...

Interview Date: February 9, 2023Company: Druva, PuneResult: Rejected.Senior Principal Engineer interview at Druva on 9 January 2023 was a nice experience delving into basi...

Shortlisting for Schlumberger online assessment based on CGPA and resume (200 shortlisted from around 1500);Online Assessment (offline): 20 Questions based on OOPS and ...

Nitin Gangahar has long list of achievements to his name and an amazing placement offer by, arguably, the best company in the world (no prizes for guessing this – it’s Goo...

LeetCode #273: Integer to English Words. Difficulty: Hard. Topics: Math, String, Recursion. Asked at Gusto in the last 6 months.

## Problem Write a function that compares two JSON-like objects (nested dicts/arrays) and returns a structured diff describing what changed between `old` and `new`. The diff should report: - `"added"`: keys present in `new` but not `old`. - `"removed"`: keys present in `old` but not `new`. - `"modified"`: keys present in both but with different values (recurse into nested objects). ```python def json_diff(old: dict, new: dict) -> dict: ... ``` **Example:** ``` old = {"a": 1, "b": {"x": 10, "y": 20}, "c": 3} new = {"a": 1, "b": {"x": 99, "z": 30}, "d": 4} json_diff(old, new) -> { "added": {"d": 4}, "removed": {"c": 3}, "modified": { "b": { "added": {"z": 30}, "removed": {"y": 20}, "modified": {"x": {"old": 10, "new": 99}} } } } ``` ## Follow-ups 1. How do you handle arrays - element-wise comparison, or treat as a whole value? 2. How would you produce a flat list of JSON Patch (RFC 6902) operations from the diff? 3. What is the time and space complexity for deeply nested structures? 4. How would you make the diff output human-readable for a UI changelog?

## Problem Implement a JSON parser from scratch, handling nested objects, arrays, strings, numbers, booleans, and null. ## Likely LeetCode equivalent No direct LC match; recursive descent parsing problem. ## Tags recursion, strings, parsing

## Round 1 - Coding ## Problem You have a set of named parameters. Each parameter's value is either a literal string or a template string referencing other parameters using `${name}` syntax. Implement a `ParameterResolver` that resolves all parameters to their final string values. Raise an error for circular references. ```python class ParameterResolver: def __init__(self, params: dict[str, str]): # params: {name -> raw value, possibly containing ${other_name}} pass def resolve(self, name: str) -> str: # Returns fully resolved string value for name pass def resolve_all(self) -> dict[str, str]: # Returns resolved values for every parameter pass ``` ## Example ``` params = { "host": "localhost", "port": "8080", "base_url": "http://${host}:${port}", "api_url": "${base_url}/api/v1" } resolver = ParameterResolver(params) resolver.resolve("api_url") # -> "http://localhost:8080/api/v1" ``` ## Circular Error Case ``` params = {"a": "${b}", "b": "${a}"} resolver.resolve("a") # -> raises CircularReferenceError ``` ## Follow-ups 1. How do you detect cycles efficiently? Describe the DFS-based approach with state coloring. 2. What if a parameter references a name that does not exist? Should it fail or leave the placeholder? 3. How would you support default values in the syntax, e.g. `${host:-127.0.0.1}`? 4. How would you extend this to support environment variable overrides at resolution time?

I was asked this question on a Phone Interview, I was not able to complete it as I struggled a little bit in order to figure it out how to...

Building a Recursive Timer ## Problem Statement You need to write a function called `timer`. This function takes one input called `seconds` (a non-negative integer). The goal is to return a string t

Written Round You have to design url shortening site bit.ly. have to enable history and expiry tracking of url. Design database for your system. Api endpoints ...

Online Test: Hackerrank Coding test of 60 mins with 2 coding questions.Technical Round 1 (60 mins): Questions on resume like previous experience and projects.Questions on ...

Round 1: Current company project in depth. We have used Kafka for some functionalities. Discussion on Kafka. Immutable classes. Discussion on hashmap. Why defa...

LeetCode #17: Letter Combinations of a Phone Number. Difficulty: Medium. Topics: Hash Table, String, Backtracking. Asked at Lyft in the last 6 months.

## Problem Calculate the total size of files in a directory tree, recursively summing nested folder sizes. ## Tags recursion, binary_tree, hash_table

## Round 1 - Coding ## Problem Implement a hyperparameter grid search generator. Given a dictionary mapping parameter names to lists of possible values, generate all possible combinations in a deterministic order. ```python def generate_configs( param_grid: dict[str, list] ) -> list[dict]: # Returns all combinations of hyperparameter values # Order: iterate last key fastest (lexicographic of keys) ... ``` ``` Example: param_grid = { "lr": [0.01, 0.1], "batch_size": [32, 64], "dropout": [0.1] } generate_configs(param_grid) -> [ {"lr": 0.01, "batch_size": 32, "dropout": 0.1}, {"lr": 0.01, "batch_size": 64, "dropout": 0.1}, {"lr": 0.1, "batch_size": 32, "dropout": 0.1}, {"lr": 0.1, "batch_size": 64, "dropout": 0.1}, ] ``` **Extension:** Implement early stopping - accept a `budget: int` and return only the first `budget` configs from a random shuffle. ```python def generate_random_configs( param_grid: dict[str, list], budget: int, seed: int = 42 ) -> list[dict]: ... ``` ## Follow-ups 1. How would you implement this as a generator (lazy evaluation) to handle huge grids? 2. What is the total config count given the example above? How do you compute it without generating all configs? 3. How does random search compare to grid search statistically? 4. How would you add support for conditional parameters (e.g. `num_layers` only applies if `model_type == "deep"`)?

## Problem Compute the nth Fibonacci number using recursion, memoization, or iterative DP. ## Likely LeetCode equivalent LC 509 - Fibonacci Number (>80% confident) ## Tags recursion, dynamic_programming, math

Using object-oriented programming, implement a task that supports recursion and memorization. Requirements: 1. Create a `Task` class supporting recursive computation of dependencies. 2. Implement a `

Given a grid of pixels representing an image where some pixels are part of objects in the image, use the provided functions to count the number of objects in the given image. ```python class Pixel:

It was off off-campus round, HR called based on the profile.There were total 4 rounds :OATechnical 1Technical 2ManagerialRound 1:It was OA assessment consists of two codin...

Total Round -4Eligibility : CSE/IT Branch with 60% and above in 12th and collegeRound 1: Aptitude round of 30 question of 1 mark each with negative marking of 0.25 which w...

There are N fishing spots and 3 gates. At each gate there are some fishermen waiting to reach the nearest unoccupied fishing spot. (Total no of fisherman =N)Distance betwe...

See All 74 Recursion Questions

Full question text, interview context, and company-specific frequency data for subscribers.

Get Access

Related Topics