Problem Library

Browse standard JavaScript & TypeScript interview questions and code review tasks

Valid Parentheses

Easy
JS / TS

Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the same type of brackets. 2. Open brackets must be closed in the correct order. 3. Every close bracket has a corresponding open bracket of the same type.

Category: Strings / Data StructuresUse for Interview

Two Sum

Easy
JS / TS

Given an array of integers `nums` and an integer `target`, return indices of the two numbers such that they add up to `target`. You may assume that each input would have exactly one solution, and you may not use the same element twice.

Category: Arrays & HashingUse for Interview

Reverse Linked List

Easy
JS / TS

Given the head of a singly linked list, reverse the list, and return the reversed list.

Category: Linked ListsUse for Interview

Implement Debounce

Easy
JS / TS

Implement a `debounce` function that delays invoking `fn` until after `delay` milliseconds have elapsed since the last time the debounced function was invoked.

Category: JavaScript UtilitiesUse for Interview

Flatten Array (Deep)

Easy
JS / TS

Write a function `flatten` that recursively flattens a nested array of arbitrary depth without using `Array.prototype.flat`.

Category: ArraysUse for Interview

Implement Memoize

Easy
JS / TS

Implement a `memoize` function that takes a function `fn` and returns a memoized version that caches results based on arguments stringification.

Category: Higher-Order FunctionsUse for Interview

Group By Polyfill

Easy
JS / TS

Write a method or function `groupBy(array, fn)` that splits an array into an object grouped by the key returned from `fn(item)`.

Category: Arrays & ObjectsUse for Interview

Code Review: Inefficient API Implementation

EasyCode Review
JS / TS

Review the following search API route handler. Identify unnecessary work, missing database pagination, over-fetching raw data, and security exposures.

Category: API & BackendUse for Interview

Code Review: Bad TypeScript Design

EasyCode Review
JS / TS

Review the following TypeScript data mapper. Identify type safety flaws, excessive `any` usage, unsafe type assertions (`as any`), and weak interfaces. Refactor for strict type safety.

Category: TypeScript & ArchitectureUse for Interview

Code Review: Poor Logging & Error Design

EasyCode Review
JS / TS

Review the following checkout payment gateway integration. Identify security logging violations, swallowed errors, lack of contextual logging, and leaking internal database stack traces to clients.

Category: Observability & Error HandlingUse for Interview

Three Sum

Medium
JS / TS

Given an integer array `nums`, return all the triplets `[nums[i], nums[j], nums[k]]` such that `i != j`, `i != k`, and `j != k`, and `nums[i] + nums[j] + nums[k] == 0`. Notice that the solution set must not contain duplicate triplets.

Category: Two PointersUse for Interview

Implement Promise.all

Medium
JS / TS

Implement a custom `promiseAll` function that accepts an array of promises (or values) and returns a single Promise that resolves to an array of results, maintaining original order. If any promise rejects, `promiseAll` rejects with that error immediately.

Category: JavaScript AsyncUse for Interview

Implement Throttle

Medium
JS / TS

Implement a `throttle` function that creates a throttled function that only invokes `fn` at most once per every `limit` milliseconds.

Category: JavaScript UtilitiesUse for Interview

LRU Cache

Medium
JS / TS

Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the `LRUCache` class: - `LRUCache(capacity)` Initialize the LRU cache with positive size capacity. - `get(key)` Return the value of key if it exists, otherwise return -1. - `put(key, value)` Update or insert the value. When capacity is reached, invalidate the least recently used item.

Category: System & Data StructuresUse for Interview

Longest Substring Without Repeating Characters

Medium
JS / TS

Given a string `s`, find the length of the longest substring without repeating characters.

Category: Sliding WindowUse for Interview

Custom Event Emitter

Medium
JS / TS

Design an `EventEmitter` class with `subscribe(eventName, callback)` and `emit(eventName, args)` methods. `subscribe` should return an unsubscribe handle object with an `unsubscribe()` method.

Category: Object-Oriented / PatternsUse for Interview

Deep Clone Object

Medium
JS / TS

Write a function `deepClone(obj)` that returns a deep copy of an object or array, handling primitives, nested objects, arrays, and dates without using `structuredClone` or `JSON.parse(JSON.stringify(obj))`.

Category: Objects & RecursionUse for Interview

Implement Currying

Medium
JS / TS

Write a function `curry(fn)` that transforms a function `fn` that accepts multiple arguments into a function that can be called repeatedly with single or multiple arguments until all expected arguments are provided.

Category: Functional ProgrammingUse for Interview

Code Review: N+1 Database Queries

MediumCode Review
JS / TS

Review the following user profile enrichment service. Identify performance issues (specifically N+1 database query patterns), explain the architectural impact on database connection pools, and propose an optimized batching/joining solution.

Category: Database & PerformanceUse for Interview

Code Review: Async Error Handling

MediumCode Review
JS / TS

Review the following payment notification pipeline. Identify problematic async behavior, missing error handling, floating unawaited promises, and failure propagation issues.

Category: Async & PromisesUse for Interview

Code Review: Promise Concurrency Exhaustion

MediumCode Review
JS / TS

Review the following batch notification dispatcher. Identify why firing thousands of HTTP requests with unrestricted `Promise.all()` leads to socket exhaustion, memory spikes, and API rate limit bans. Refactor with controlled concurrency.

Category: Async & ConcurrencyUse for Interview

Code Review: Authorization & Security Bug

MediumCode Review
JS / TS

Review the following document sharing API endpoint. Identify the critical security flaw (Insecure Direct Object Reference - IDOR), explain how an attacker could exploit it, and implement proper authorization checks.

Category: Security & AuthUse for Interview

Code Review: Overengineered Code

MediumCode Review
JS / TS

Review the following user name formatting module. Identify unnecessary design abstractions, premature generalization, and refactor it into a clean, simple, readable function.

Category: Software DesignUse for Interview

Implement Concurrency Limiter

Hard
JS / TS

Implement a `ConcurrencyLimiter` class (or function) that manages async task execution, ensuring that no more than `maxConcurrency` tasks run simultaneously while queueing additional tasks.

Category: Async Control FlowUse for Interview

Code Review: Race Condition & State Mutability

HardCode Review
JS / TS

Review the following wallet balance transfer handler. Identify how concurrent operations produce inconsistent state, explain the race condition window, and refactor using atomic operations or database transactions.

Category: Concurrency & StateUse for Interview

Code Review: Node.js Memory Leak

HardCode Review
JS / TS

Review the following WebSocket stream manager and query cache. Identify why process memory grows continuously over time, locate uncleaned event listeners/timers, and propose a leak-free implementation.

Category: Node.js & MemoryUse for Interview
Click any problem to view details and preview description.