JavaScript function challenges.
The JavaScript problems LeetCode keeps behind Premium are the same utilities frontend interviews ask for: a promise pool, throttle, curry, deep equal, deep merge and query batching. Each one here is written for UIRound, with tests that run in your browser and a step-by-step answer. UIRound is not affiliated with LeetCode.
7 of these questions have free answers; the rest are in Pro. Updated .
45
questions
- Easy
- 13
- Medium
- 27
- Hard
- 5
What interviewers look for
- You handle timing exactly: leading and trailing calls, windows that start at the right moment, and timers you can cancel.
- You keep promise results in order and settle every caller, including when a task throws or rejects.
- You walk nested data safely: cycles, arrays versus objects, holes, and keys like __proto__.
- You keep this, arguments and placeholders right when you wrap a function in bind, curry or partial.
Easy13
- Implement
Function., including partial argumentsFreeImplement Function.prototype.myBind(thisArg, ...boundArgs) without using the built-in bind. It returns a new function…prototype. bind() - Implement a basic
deepEqual()for nested arrays and objectsImplement deepEqual(a, b). It returns true when two values have the same structure and the same primitive values,… - Merge busy calendar slots and find free time for a meetingA meeting scheduler collects everyone's busy times and offers free slots. Implement two functions. Times are minutes…
- Implement
forEach,some,every,findandfindIndexpolyfillsAfter map, filter and reduce (questions 1–3), interviewers often ask for the other array iteration methods. Implement… - Implement binary search and its variants: insert position, first and last match, rotated arraysFreeBinary search is the algorithm most often asked in frontend DSA rounds, because its off-by-one errors separate careful…
- Build chainable APIs: a
CarwithaddSpeed()., and a proxy that records any method chain"Make these calls chain" has been reported in public interview write-ups in two forms: a class whose methods chain, like…minus() - Build a lazy nested list iterator with
hasNext()andnext()that also accepts sets and generatorsWrite a class that walks a nested list such as [1, [2, [3, 4]], 5] one value at a time. The interviewer usually starts… - Replace every
undefinedwithnullin nested dataJSON.stringify silently drops object keys whose value is undefined, so { middleName: undefined } is sent as {}. Many… - Invert an object, collecting duplicate values into arraysInverting an object swaps keys and values: { en: "English", fr: "French" } becomes { English: "en", French: "fr" }. When…
- Find the row with the most 1s in a row-sorted binary matrixEach row of a binary matrix is sorted: all its 0s come before all its 1s. Find the row with the most 1s.
- Encode a list of strings into one string and decode it back exactlyTwo systems can only exchange a single string, but you need to send a whole list of strings. Write encode(strings),…
- Write two generators: walk an array in circular jumps, and yield factorials as BigIntGenerators can pause, hand back a value, and receive one on the way back in. Write two of them.
- Implement
String.with O(log n) concatenations by doubling"ab".repeat(3) returns "ababab". Write repeatString(str, count), which behaves like String.prototype.repeat, without…prototype. repeat()
Medium27
- Implement
throttle()with leading and trailing optionsFreeImplement throttle(fn, wait, { leading = true, trailing = true } = {}). The throttled function calls fn at most once per… - Implement
curry()supporting partial applicationFreeImplement curry(fn). It returns a curried version of fn that keeps collecting arguments until it has at least fn.length… - Implement
JSON.for common data types and edge casesImplement stringify(value) so that it returns exactly what JSON.stringify(value) returns, without calling…stringify() - Implement
Promise.FreeImplement promiseAllSettled(iterable) without using Promise.allSettled. It returns a promise that always fulfils, once…allSettled() - Implement
promisify()for callback-based APIsMany older APIs take a Node-style callback as their last argument: callback(error, result). Implement promisify(fn),… - Implement
promisePool()using worker loopsImplement promisePool(tasks, concurrency, { settle = false } = {}). tasks is an array of functions that each return a… - Write a deep
mergethat is safe from prototype pollutionConfig loaders, query-string parsers and "settings" endpoints often deep-merge user-controlled JSON into an object. A… - Build tic-tac-toe on an N×N board with M in a row to winFreeBuild a TicTacToe component that works on any board size, with two props: size = 3 (the board is size × size) and…
- Build the Snake game with a pure game loopBuild Snake in two layers: pure game logic that is easy to test, and a React component that runs it.
- Deep-diff two objects and apply the changes as a patch"Find the difference between two objects" comes up in interviews and in real work: undo history, "unsaved changes"…
- Use
ProxyandReflectfor validation, negative indexes, change tracking and read-only views"What is a Proxy and when would you use one?" usually turns into "write one". Proxy is how Vue 3 and MobX track state… - Implement
curry()with placeholders that later calls fill left to rightQuestion 28 builds curry(fn) that collects arguments in order. Lodash and Ramda also let you skip an argument with a… - Model a file system: O(1) path lookup, create/get/set, print the tree and composable search filtersThis task has been reported in public interview write-ups in several forms: "pick a data structure for a directory tree…
- Build an immutable
PlainDate: month arithmetic with end-of-month clamping, day differences without time zones, ISO weeks and comparisonBirthdays, due dates and billing days are calendar dates, not instants. Storing them in a Date ties them to a time zone:… - Find the fewest meeting rooms needed for a list of meetingsMeetings are pairs [start, end] of numbers with start < end. A meeting occupies its room from start up to, but not…
- Deep-filter a nested object by a predicate and drop empty branchesYou have a large settings or API object and want only the parts that match a rule, for example "only the numbers" or…
- Write generators that flatten nested arrays lazily and walk a date rangeArray.prototype.flat builds the whole result at once, and a loop over dates written with local time skips or repeats a…
- Build an interval whose delay grows on every run, with a clear functionA reconnect loop should wait 1 s, then 2 s, then 3 s, and stop as soon as the connection is back. setInterval uses one…
- Build a throttled query batcher: send the first key at once, then batch the rest per windowA dashboard renders dozens of widgets, and each one asks for a user by id the moment it mounts. One request per widget…
- Recover an alien alphabet from a sorted word list with topological sortA dictionary written in an alien language is sorted by the alien alphabet, which uses ordinary characters in an unknown…
- Count events over a sliding window: a logger rate limiter, a hit counter and a moving averageAnalytics, logging and rate limiting all ask the same question: what happened in the last few seconds? Build three small…
- Count the connected components of an undirected graph with union-findA design system's components reference each other; a social graph links users; a spreadsheet's cells depend on one…
- Find the fewest knight moves to a square on an infinite chessboardA knight moves two squares in one direction and one square at right angles: eight possible moves. On an infinite…
- Read n characters from a source that only returns four at a time, keeping the leftovers between callsSome sources only give data in fixed chunks: a decoder that emits 4 bytes at a time, a paginated API with a fixed page…
- Store logs by timestamp and retrieve them by year, month, day, hour, minute or secondLogs, analytics events and audit trails are usually queried by time range at a chosen precision: "everything on 1 Jan",…
- Simulate Candy Crush: crush lines of three or more, drop the candies and repeat until the board is stableMatch-3 games (Candy Crush, Bejeweled) run the same loop after every swap: remove lines of matching candies, let the…
- Turn an array of nested objects into a table: dotted column paths, sorted headers and blanks for missing valuesExporting data to CSV, rendering it in a spreadsheet-like grid or comparing records side by side all need the same step:…
Hard5
- Implement an autocomplete search engine using a TrieFreeImplement a Trie class that powers search-box suggestions:
- Implement Immer's
produce()with copy-on-write proxiesRedux Toolkit and many React apps use Immer, which lets you write "mutating" code that produces an immutable update.… - Serialize, deserialize and traverse a binary tree: level order and vertical orderTrees are everywhere in frontend work: the DOM, a component tree, a comment thread, a file explorer. Interviewers often…
- Decide whether a set of edges forms a valid tree with union-find, undirected and rootedA workflow builder lets people connect steps with arrows, and it only accepts diagrams that form a tree. Nodes are…
- Clean every reachable cell with a blind robot that can only move, turn and cleanA robot vacuum is placed in a room it cannot see. It does not know the layout or its position. It only has four…
Practise with tests and full answers.
Every question has a runnable editor, tests and a step-by-step solution. Passes from ₹149, paid once; nothing renews.
Frequently asked
Are these the same problems as on LeetCode?
They test the same ideas, written independently for UIRound with their own wording, examples and tests. Several go further, with the cancellation, cycles and ordering rules that interviewers add as follow-ups.
Which of these come up most in frontend interviews?
Throttle, curry, deep equal, deep merge, promisify and a promise pool with a concurrency limit. Query batching and an Immer-style produce come up more in senior rounds.
Do I need a LeetCode subscription to practise them?
No. Every problem here can be read on UIRound without an account, and the step-by-step answers and full solutions come with Pro.