Filter by the role you are applying for, open a question, and practise explaining the answer out loud. Mark it practised when you can.
Why they ask this: The most common warm-up problem; it checks whether you can trade memory for speed with a hash map.
Given an array of integers nums and an integer target, return the indices of the two numbers that add up to target. Assume exactly one solution exists, and…
Why they ask this: A fundamental algorithm; off-by-one errors in the loop are exactly what interviewers look for.
Given a sorted (ascending) array of distinct integers nums and a target, return the index of target, or -1 if it is not present. Your solution must run in O(log…
Why they ask this: A quick check of loops, indexes and the difference between bytes and characters.
Write a function that returns the reverse of a string. Try it without using a built-in reverse helper first. Example
Why they ask this: Tests the two-pointer technique and careful handling of edge cases like spaces and punctuation.
A phrase is a palindrome if, after converting all letters to lowercase and removing every non-alphanumeric character, it reads the same forwards and…
Why they ask this: Filters out candidates who cannot write a simple loop with conditions; order of checks is the classic trap.
Return a list of strings for the numbers 1 to n where: multiples of 3 become "Fizz", multiples of 5 become "Buzz", multiples of both 3 and 5 become…
Why they ask this: Checks counting with a hash map and comparing frequency, a pattern used in many string problems.
Given two lowercase strings a and b, return true if b is an anagram of a (it uses exactly the same letters the same number of times), otherwise false. Example 1…
Why they ask this: A classic dynamic programming problem that shows whether you can improve an O(n²) idea to O(n).
Given an integer array nums with at least one element, find the contiguous subarray with the largest sum and return that sum. Example 1 Example 2
Why they ask this: Checks basic use of sets or hash maps, and whether you think about preserving order.
Given an array of integers, return a new array with duplicates removed, keeping the first occurrence of each value in its original order. Try it without a…
Why they ask this: Tests recursion and how you handle data of unknown depth, which is common with JSON from APIs.
Given an array that can contain numbers and other arrays nested to any depth, return a single flat array with all the values in their original order. Example
Why they ask this: The standard stack problem; it shows you can pick the right data structure for matching pairs.
Given a string s containing only the characters (, ), {, }, [ and ], return true if: every opening bracket is closed by the same type of bracket, and brackets…