Coding Challenges
Quick, focused coding puzzles you can solve right in the browser. Tests run live, your streak is tracked, and a new daily challenge is picked for everyone each day.
Valid Parentheses
Given a string `s` containing only the characters `()[]{}`, return `true` if it is a valid, properly nested bracket sequence.
Start daily challenge →Algorithms
10Two Sum
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 exactly one solution exists, and you may not use the same element twice.
Reverse String
Write a function that reverses a string. The input is given as an array of characters. Modify the array in-place and return the reversed array.
FizzBuzz
Return an array containing strings from 1 to `n`. For multiples of 3 use "Fizz", for multiples of 5 use "Buzz", for multiples of both use "FizzBuzz". Otherwise, use the number as a string.
Palindrome Check
Given a string, return `true` if it is a palindrome considering only alphanumeric characters (case-insensitive). Otherwise return `false`.
Fibonacci
Return the n-th Fibonacci number where F(0) = 0, F(1) = 1, and F(n) = F(n-1) + F(n-2) for n > 1.
Binary Search
Given a sorted array of integers `nums` and a `target`, return the index of `target` if found. Otherwise return -1. Your algorithm must run in O(log n) time.
Merge Sorted Arrays
Given two sorted arrays `a` and `b`, return a new sorted array containing all elements from both inputs. O(n + m) time expected.
Maximum Subarray Sum
Given an integer array `nums`, return the largest sum of any contiguous subarray. (Kadane's algorithm.)
Valid Parentheses
Given a string `s` containing only the characters `()[]{}`, return `true` if it is a valid, properly nested bracket sequence.
Rotate Array
Rotate the array `nums` to the right by `k` steps, where `k` is non-negative. Return the rotated array.
String Manipulation
5Anagram Check
Given two strings `s` and `t`, return `true` if `t` is an anagram of `s` (same characters, same counts), otherwise `false`. Consider them case-sensitive.
Longest Substring Without Repeats
Given a string `s`, return the length of the longest substring without repeating characters.
Count Vowels
Return the number of vowels (a, e, i, o, u — case-insensitive) in the given string.
Capitalize Words
Capitalize the first letter of every whitespace-separated word in the given sentence. All other letters should be lowercased.
Remove Duplicate Characters
Given a string, return a new string with duplicate characters removed while preserving the order of first appearance.
JavaScript Quirks
5Type Coercion: Sum as Number
The expression `"5" + 3` produces `"53"` because `+` coerces numbers to strings when one operand is a string. Implement `addAsNumbers(a, b)` that always returns the numeric sum, even when inputs are numeric strings.
Closure Counter
Implement `createCounter()` that returns an object with three methods: `increment()`, `decrement()`, and `value()`. The counter should start at 0 and persist state across calls via a closure. Each call to `createCounter()` must return an independent counter.
Deep Clone
Implement `deepClone(obj)` that returns a deep copy of the given object. The result should be structurally equal to the input but should NOT share nested references. Assume inputs are plain JSON-safe values (primitives, arrays, plain objects).
Flatten Array
Implement `flatten(arr)` that recursively flattens a nested array of any depth into a single-level array. Do not use `Array.prototype.flat(Infinity)`.
Debounce Function
Implement `debounce(fn, wait)` which returns a function that delays invoking `fn` until `wait` ms have elapsed since the last call. For the tests, call `debounce(fn, 10)` and verify it returns a callable function. We will manually test its behavior.
Debugging
5Fix Off-By-One
This function is supposed to return the sum of numbers from 1 to n inclusive, but it has an off-by-one bug. Fix it so the tests pass.
Fix Mutation Bug
`addItem` should return a NEW array with the item appended, not mutate the input. Fix it so the original array is unchanged and the returned array contains the new item.
Fix Async Race
`fetchInOrder` should return an array of results in the same order as the input promises resolve conceptually — i.e. the order of the inputs. The current implementation relies on resolution order, which is buggy. Fix it so the returned array preserves input order even if later promises resolve first.
Fix Missing Return
`double` is supposed to return an array with every element doubled, but something is missing. Fix the function.
Fix Typo in Loop
`reverseArray` should return the input array reversed. There is a typo in the loop bounds that causes it to return the wrong result. Find and fix it.
Regex
5Email Validator
Return `true` if the input is a reasonably valid email address (format: [email protected], with a TLD of 2+ letters). Use a regular expression.
URL Matcher
Return `true` if the input is a valid http or https URL, `false` otherwise.
Extract Numbers
Given a string, return an array of all integers found (as numbers). Preserve order of appearance.
Validate Phone Number
Return `true` if the input is a valid North American phone number in the format (XXX) XXX-XXXX, XXX-XXX-XXXX, or XXX.XXX.XXXX.
Split camelCase
Given a camelCase string, return an array of its lowercase component words. E.g. "camelCaseString" → ["camel", "case", "string"].