Interview prep
Coding Patterns interview questions
33 of the most common Coding Patterns questions for data and AI interviews — each with a worked answer, the trap to avoid, and a link to learn it properly. The reusable algorithm patterns behind coding rounds — two pointers, sliding window, hashing, BFS/DFS, DP.
Filter by role
- Implement binary search correctly — and explain the off-by-one traps. Easy ·Amazon·Google·Meta
- How many distinct ways can you climb n stairs if you can take 1 or 2 steps at a time? Easy ·Amazon·Google·Meta
- You are a robber. Given an array of house values, find the maximum money you can rob without robbing two adjacent houses. Easy ·Amazon·Google·Meta
- Find the contiguous subarray with the largest sum (Kadane's algorithm). Easy ·Amazon·Google·Meta
- Find the kth largest element in an unsorted array without fully sorting it. Easy ·Amazon·Google·Meta
- Detect whether a linked list has a cycle using Floyd's fast/slow pointer algorithm. Easy ·Amazon·Google·Meta
- Find the maximum depth (height) of a binary tree. Easy ·Amazon·Google·Meta
- Merge two sorted linked lists into one sorted list. Easy ·Amazon·Google·Meta
- Design a stack that returns its minimum element in O(1). Easy ·Amazon·Google·Meta
- How do you remove duplicates from a sorted array in place? Easy ·Amazon·Google·Meta
- Reverse a singly linked list, iteratively and recursively. Easy ·Amazon·Google·Meta
- Find the maximum average of any contiguous subarray of size k. Easy ·Amazon·Google
- Given a sorted array, find two numbers that add up to a target — how do you do it in O(n) without extra space? Easy ·Amazon·Google·Meta
- Check whether a string of brackets is valid. Easy ·Amazon·Google·Meta
- Return the level-order (BFS) traversal of a binary tree as a list of lists, one per level. Medium ·Amazon·Google·Meta
- Given a list of coin denominations and a target amount, find the fewest coins needed to make that amount (coin change). Medium ·Amazon·Google·Meta
- Find all unique combinations of candidates that sum to a target, where each candidate may be used an unlimited number of times. Medium ·Amazon·Google·Meta
- Given an array of heights, find two lines that together with the x-axis form a container that holds the most water. Medium ·Amazon·Google·Meta
- For each day, how many days until a warmer temperature? Medium ·Amazon·Google·Meta
- Group a list of words into anagrams. Medium ·Amazon·Google·Meta
- Find the minimum eating speed for Koko to finish all bananas within h hours. Medium ·Amazon·Google·Meta
- Find the length of the longest common subsequence (LCS) of two strings. Medium ·Amazon·Google·Meta
- Find the length of the longest substring without repeating characters. Medium ·Amazon·Google·Meta
- Given a list of intervals, merge all overlapping intervals and return the result. Medium ·Amazon·Google·Meta
- Find the minimum length of a contiguous subarray whose sum is at least a given target. Medium ·Amazon·Google
- Given a 2-D grid of '1's (land) and '0's (water), count the number of islands (connected components of land). Medium ·Amazon·Google·Meta
- Generate all permutations of a list of distinct integers using backtracking. Medium ·Amazon·Google·Meta
- Count the number of contiguous subarrays whose sum equals k. Medium ·Amazon·Google·Meta
- Return an array where each element is the product of all other elements, without using division. Medium ·Amazon·Google·Meta
- Search for a target in a rotated sorted array in O(log n). Medium ·Amazon·Google·Meta
- Generate all subsets of a set — the power set — using backtracking. Medium ·Amazon·Google·Meta
- Find all unique triplets in an array that sum to zero (3Sum). Medium ·Amazon·Google·Meta
- Return the k most frequent elements in an array. Medium ·Amazon·Google·Meta
No questions tagged for that role yet.