Top Algorithms Interview Questions (2026)
Practice the 42 most-asked Algorithms interview questions, each with a model answer, key points, and the mistakes to avoid. Filter by difficulty, reveal answers, and rate your confidence to track how interview-ready you are.
42 questions Open in question bank
Algorithms questions
- Find the k-th largest element in an unsorted array.
[Heap]Intermediate· coding₹99 (Interview Prep or Pro plan required) - Count the number of islands in a 2D grid of land and water.
[BFS/DFS]Intermediate· coding₹99 (Interview Prep or Pro plan required) - Given a collection of intervals, merge all overlapping intervals.Intermediate· coding₹99 (Interview Prep or Pro plan required)
- There are numCourses labeled 0..n-1 with prerequisite pairs. Return an ordering in which you can finish all courses, or empty if impossible (Course Schedule II).Advanced· coding₹99 (Interview Prep or Pro plan required)
- Given a sorted array, find the k closest integers to a target x (x may not be in the array). Return them in ascending order.Intermediate· coding₹99 (Interview Prep or Pro plan required)
- Given a sorted dictionary of an alien language (list of words in lexicographic order), derive the order of its characters (Alien Dictionary).Advanced· coding₹499 (Pro plan required)
- Implement atoi: convert a string to a 32-bit signed integer, handling whitespace, sign, and overflow (String to Integer).Intermediate· coding₹99 (Interview Prep or Pro plan required)
- Given a string and a dictionary of words, determine whether the string can be segmented into a space-separated sequence of dictionary words (Word Break).Intermediate· coding₹99 (Interview Prep or Pro plan required)
- Given a weighted graph, find the minimum-cost path from a source to a destination.Intermediate· coding₹99 (Interview Prep or Pro plan required)
- House Robber: given an array of house values, maximize the sum you can rob without robbing two adjacent houses.Intermediate· codingFree
- Given a board of characters and a list of words, return all words that can be formed by sequentially adjacent cells (Word Search II).Advanced· coding₹499 (Pro plan required)
- Count the number of connected components in an undirected graph (or islands in a grid), and discuss the incremental/streaming version.Intermediate· coding₹99 (Interview Prep or Pro plan required)
- Given a large log/event stream, find the top K most frequent elements efficiently.Intermediate· coding₹99 (Interview Prep or Pro plan required)
- Maximum Points You Can Obtain from Cards: given an array
cardPointsand integerk, you take exactly k cards from either the beginning or the end each turn. Return the maximum total points obtainable.Intermediate· coding₹99 (Interview Prep or Pro plan required) - Given an array of words and a maximum line width L, format the text so that each line has exactly L characters and is fully (left and right) justified. Pack as many words per line as possible and distribute extra spaces as evenly as possible; the last line and any line with a single word are left-justified.Advanced· coding₹499 (Pro plan required)
- Given a menu as a list of item prices and a target value K, find all possible combinations of items that sum to exactly K. (A variation of the classic combination-sum / N-sum problem asked in Airbnb's first round.)Intermediate· coding₹99 (Interview Prep or Pro plan required)
- Write a method to parse an input string in CSV format. Handle quoted fields that may contain commas and escaped double quotes (a doubled "" inside a quoted field represents a literal quote).Intermediate· coding₹99 (Interview Prep or Pro plan required)
- Cheapest Flights Within K Stops: given n cities, a list of flights [from, to, price], a source, a destination and an integer K, return the cheapest price from source to destination with at most K stops, or -1 if it is not possible.Advanced· coding₹499 (Pro plan required)
- Given two strings s and t, determine if they are isomorphic - characters in s can be replaced to get t with a consistent one-to-one mapping (no two characters map to the same character). (LeetCode 205 - Isomorphic Strings)Beginner· codingFree
- Given a flowerbed as an array of 0s and 1s (0 = empty, 1 = planted) where no two flowers may be adjacent, determine if n new flowers can be planted without violating the no-adjacent rule. (LeetCode 605 - Can Place Flowers)Beginner· codingFree
- Given exchange rates as a string like "USD:CAD:1.2,CAD:GBP:0.6,USD:AUD:1.4", write a function that converts an amount from a source to a target currency, including multi-step paths (USD to GBP via CAD). Then extend it to return the best achievable rate when several paths exist, and handle rates that form an arbitrage cycle.Intermediate· coding₹499 (Pro plan required)
- Implement a retry helper that calls a flaky function (e.g. a payment or API call) and retries on failure using exponential backoff with jitter, a maximum number of attempts, and a maximum delay cap. Only retry on transient/retryable errors.Intermediate· coding₹99 (Interview Prep or Pro plan required)
- Amazon OA: A recursive function computes Fibonacci as fib(n)=fib(n-1)+fib(n-2) with no memoization. What is its time complexity?Beginner· multiple choiceFree
- Google OA: What is the time complexity of finding the k-th smallest element in an unsorted array of n elements using the Quickselect algorithm, on average?Intermediate· multiple choice₹99 (Interview Prep or Pro plan required)
- Google OA: Which algorithm correctly finds shortest paths from a single source in a graph that contains negative edge weights but no negative cycles?Intermediate· multiple choice₹99 (Interview Prep or Pro plan required)
- Microsoft OA: What is the time complexity of the standard dynamic-programming solution to the 0/1 Knapsack problem with n items and capacity W?Intermediate· multiple choice₹99 (Interview Prep or Pro plan required)
- Meta OA: What is the time complexity of computing whether two strings are anagrams by counting character frequencies, for strings of length n over a fixed alphabet?Beginner· multiple choiceFree
- Meta OA: In graph terms, finding the minimum number of edges between two nodes in an unweighted graph is best done with which algorithm?Beginner· multiple choiceFree
- Meta OA: For the problem 'given n intervals, find the minimum number of meeting rooms required', which approach is optimal?Advanced· multiple choice₹99 (Interview Prep or Pro plan required)
- Which technique solves "best value under a running constraint" problems such as 0/1 knapsack by storing answers to overlapping subproblems, and which two properties make a problem suitable for it?Intermediate· multiple choice₹99 (Interview Prep or Pro plan required)