What should I focus on when preparing?
Which topics should I start with?
Start with arrays and strings. They appeared in 128 of 374 interviews, more than any other topic. Hash maps and sets came next, followed by basics and complexity.
Use these checks to find what you need to review:
- Can you solve array and string problems using scans, two pointers, sliding windows, prefix sums, and frequency counts?
- Can you check edge cases in your array and string code?
- Can you explain the time and space your code uses with Big-O notation?
For each approach, check whether you can write the code as well as explain it. Knowing the name of a technique is not the same as completing the task.
Which coding tasks should I check first?
A coding task appeared in 209 of 374 interviews. Two Sum was the most asked question, appearing in 26 of 374 interviews.
Check the exact requirement, not just the problem name:
- Does your Two Sum function return the matching indices, and can you explain its time complexity?
- Can your palindrome checker ignore case and characters that are not letters or numbers?
- Can you reverse a string in place without allocating another array?
- Can you generate Fibonacci terms with a loop or recursion, adding the previous two terms each time?
Reviewed Two Sum answers missed a working function that returned the matching indices. Reviewed Fibonacci answers missed code that generated the terms as required. Check your implementation against those requirements.
Can I explain how a hash map works?
Reviewed Java HashMap answers missed a specific step: how a key’s hash determines its bucket index before keys within that bucket are compared.
Can you explain that sequence in plain words? Also check whether you can explain collisions, resizing, and key equality. For collection comparisons, can you describe how arrays and linked lists differ in memory layout and operations?
What should I check beyond arrays and maps?
Use these tasks to check other topics:
- Implement binary search, explain when it applies, and give its time complexity.
- Compare merge sort, quicksort, and heap sort, including their time complexities.
- Explain how you represent a tree or graph and how you visit its nodes.
- Explain how a stack supports bracket checking or expression evaluation.
- Describe an algorithm choice for a cache, rate limiter, or scheduling problem.
Who gets asked Data Structures and Algorithms
The 20 most asked Data Structures and Algorithms questions
Counted by interview, not by mention: a question asked twice in one conversation counts once.
Write a Two Sum function returning the matching indices, and explain its time complexity.
Asked in 26 of 374 interviews · last asked Oct 23 · Write code · Junior
Show answer
Use a hash map to return the indices of two numbers whose sum equals the target. For each number, look for its complement, then store the number and its index. One pass takes O(n) time on average because hash-map operations take O(1) on average. Extra space is O(n).
- The complement is the target minus the current number.
- Check before storing so the same index is not used twice.
- Duplicate values work when they occur at different indices.
- Return one matching pair, or an empty list if no pair exists.
Pythondef two_sum(nums, target): seen = {} for i, value in enumerate(nums): complement = target - value if complement in seen: return [seen[complement], i] seen[value] = i return []What the interviewer checks: The interviewer checks whether you can write correct code and explain how a hash map avoids checking every pair.
Common mistake (in 7 of 10 reviewed answers): Many answers forget that the function must return two distinct indices, not the matching values.
Other ways it was asked
- “Write a function that solves the Two Sum problem.”
- “What is the time complexity of a solution to the Two Sum problem?”
- “What is the time complexity of your Two Sum solution?”
Write a palindrome checker, and explain how to ignore case and non-alphanumeric characters.
Asked in 13 of 374 interviews · last asked Oct 22 · Write code · Junior
Show answer
Keep only letters and numbers, make case differences irrelevant, and compare the result with its reverse. In Python, use casefold() to ignore case and isalnum() to filter characters. If the cleaned string equals its reverse, it is a palindrome.
- This solution takes O(n) time and O(n) extra space.
- Empty strings and strings with no letters or numbers count as palindromes.
- Python's isalnum() accepts Unicode letters and numbers, not just ASCII.
Pythondef is_palindrome(text: str) -> bool: cleaned = ''.join(char for char in text.casefold() if char.isalnum()) return cleaned == cleaned[::-1] assert is_palindrome('A man, a plan, a canal: Panama!') assert not is_palindrome('hello') assert is_palindrome('!!!')What the interviewer checks: The interviewer is checking whether you can compare characters correctly, clean the input, and explain edge cases and cost.
Other ways it was asked
- “How would you check whether a string is a palindrome?”
- “How can you identify whether a word is a palindrome?”
- “Can you write code to determine whether a string is a palindrome?”
Write code to reverse a string in place without allocating another array.
Asked in 9 of 374 interviews · last asked Oct 12 · Write code · Junior
Show answer
Swap the first and last characters, then move inward until the pointers meet. Java strings are immutable, so true in-place reversal needs an existing mutable array, such as char[]. This code reverses that array without allocating another array.
- Time is O(n), and extra space is O(1).
- Empty arrays and single-character arrays stay unchanged.
- Java char values are UTF-16 code units; reversing them can break surrogate pairs.
Codeclass Solution { static void reverse(char[] chars) { int left = 0, right = chars.length - 1; while (left < right) { char temp = chars[left]; chars[left++] = chars[right]; chars[right--] = temp; } } }What the interviewer checks: The interviewer checks whether you can use two pointers, avoid extra storage, and recognize that Java strings are immutable.
Other ways it was asked
- “Write code to reverse a string.”
- “Write Java code to reverse a string.”
- “How would you write code to reverse a string?”
Write a program to generate the Fibonacci series.
Asked in 8 of 374 interviews · last asked Oct 14 · Write code · Junior
Show answer
I generate the first n Fibonacci numbers, starting with 0 and 1. Each later number is the sum of the previous two. This Python solution uses a loop and returns the numbers in a list.
- Update both values together so the calculation uses their old values.
- For n = 0, return an empty list; reject negative n.
- Time is O(n), and the returned list uses O(n) space, assuming constant-cost integer arithmetic.
Pythondef fibonacci(n): if n < 0: raise ValueError("n must be non-negative") result = [] a, b = 0, 1 for _ in range(n): result.append(a) a, b = b, a + b return result print(fibonacci(7)) # [0, 1, 1, 2, 3, 5, 8]What the interviewer checks: The interviewer checks whether you can use a loop, update values correctly, and handle small inputs.
Common mistake (in 5 of 5 reviewed answers): Many answers forget that each new term must be computed as the sum of the previous two.
Other ways it was asked
- “Write a Python program to display the Fibonacci series.”
- “Write a Python program for the Fibonacci series.”
- “Can you write Python code to generate the Fibonacci sequence?”
Write code to find the largest number in an array.
Asked in 6 of 374 interviews · last asked Oct 24 · Write code · Junior
Show answer
Scan the array once, keeping the largest value seen so far. Start with the first element so negative numbers work correctly. For an empty array, this function raises an error because there is no largest value.
- One scan takes O(n) time and O(1) extra space.
- Start with the first element, not zero.
- Handle an empty array explicitly.
Pythondef find_largest(numbers): if not numbers: raise ValueError("Array must not be empty") largest = numbers[0] for number in numbers: if number > largest: largest = number return largestWhat the interviewer checks: The interviewer checks whether you can scan an array, track a maximum, and handle edge cases.
Other ways it was asked
- “How would you find the maximum element in an array?”
- “How would you find the maximum element in an array and count how many times it appears?”
- “How would you find the largest number in a Java array?”
What is the difference between an array and a linked list?
Asked in 6 of 374 interviews · last asked Sep 30 · Concept · Junior
Show answer
An array stores elements in one continuous memory block. A linked list stores nodes connected by links, which may be scattered in memory. Array access by index is O(1); linked list access by index is O(n). Python's built-in list is a dynamic array, not a linked list.
- Array insertion or deletion can take O(n) because elements may need to shift.
- Linked list insertion or deletion is O(1) with the required node and predecessor references; finding them takes O(n).
- Linked lists need extra memory for links; arrays usually make better use of CPU caches.
What the interviewer checks: The interviewer checks whether you understand memory layout, access speed, update costs, and language-specific naming.
Other ways it was asked
- “What is the difference between an array and a list?”
- “What is the difference between a list and an array in Python?”
What are the differences between ArrayList and LinkedList in Java?
Asked in 6 of 374 interviews · last asked Oct 16 · Concept · Junior
Show answer
ArrayList uses a resizable array, while LinkedList uses a doubly linked list. Both implement Java's List interface. ArrayList provides O(1) access by index, while LinkedList takes O(n). ArrayList shifts elements for middle insertions or removals; LinkedList changes links in O(1), but finding the position takes O(n).
- ArrayList appends take O(1) amortized time; resizing can take O(n).
- LinkedList adds or removes elements at either end in O(1) and also implements Deque.
- An already-positioned LinkedList ListIterator can insert or remove in O(1).
- ArrayList usually uses less memory and is faster to iterate because its storage is more compact.
What the interviewer checks: The interviewer checks whether you can connect each internal structure to its performance and choose the right list.
Other ways it was asked
- “What is the difference between ArrayList and LinkedList?”
- “What is the difference between Java's ArrayList and LinkedList?”
- “What is the difference between the List interface and LinkedList in Java?”
How does HashMap work internally in Java?
Asked in 6 of 374 interviews · last asked Oct 16 · Concept · Senior
Show answer
Java's HashMap stores key-value pairs in an array of buckets. It mixes the key's hashCode() and uses that hash to choose a bucket. Within the bucket, it checks hashes and compares keys with equals(). Collisions use linked lists; in Java 8 and later, crowded buckets can become red-black trees.
- The bucket index is (capacity - 1) & mixedHash; capacity is a power of two.
- Tree conversion requires at least 64 buckets; smaller tables resize instead.
- The default load factor is 0.75; exceeding the size threshold normally doubles capacity and redistributes entries.
- get() and put() take O(1) time on average when hashes spread keys well.
What the interviewer checks: The interviewer checks whether you understand bucket selection, key comparison, collisions, and resizing.
Common mistake (in 5 of 6 reviewed answers): Many answers forget that the hash selects a bucket before keys inside that bucket are compared.
Other ways it was asked
- “How does Java's HashMap work?”
- “How does HashMap work in Java?”
- “How does HashMap handle internal operations in modern Java?”
What is a hash map, and how does it store and retrieve values by key?
Asked in 6 of 374 interviews · last asked Sep 18 · Concept · Junior
Show answer
A hash map stores key-value pairs. It uses a hash function to turn each key into an array position. To retrieve a value, it hashes the key again and compares keys to find the matching entry, handling cases where different keys map to the same position.
- Lookup, insertion, and deletion take O(1) time on average with good hashing.
- Collisions are handled by storing multiple entries together or searching other array positions.
- Equal keys must have equal hash values, but different keys may share a hash value.
- Worst-case operations can take O(n) time, depending on the implementation.
What the interviewer checks: The interviewer checks whether you understand hashing, key comparison, collisions, and average lookup speed.
Other ways it was asked
- “What is a HashMap?”
- “What is a HashMap in Java?”
- “How does a hash table use a unique identifier to look up a record?”
Compare merge sort, quicksort, and heap sort, including their time complexities.
Asked in 6 of 374 interviews · last asked Oct 9 · Concept · Junior
Show answer
Standard merge sort takes O(n log n) time in the best, average, and worst cases. Quicksort takes O(n log n) in the best and average cases, but O(n²) in the worst case. Heap sort takes O(n log n) on average and in the worst case.
- Merge sort can preserve equal elements' order, making it stable; array implementations usually need O(n) extra space.
- Typical recursive quicksort uses O(log n) stack space on average, but O(n) in the worst case.
- Quicksort is usually not stable; randomized pivots reduce the risk of poor splits.
- Heap sort is not stable, uses O(1) extra space, and guarantees O(n log n) worst-case time.
What the interviewer checks: The interviewer checks whether you can compare time guarantees, memory use, and stability when choosing a sorting algorithm.
Other ways it was asked
- “What is the time complexity of merge sort and quicksort?”
- “What are the time complexities of bubble sort and merge sort?”
- “What is the time complexity of merge sort?”
Implement binary search, explain when it applies, and give its time complexity.
Asked in 6 of 374 interviews · last asked Sep 14 · Concept · Junior
Show answer
Binary search finds a target in a sorted array by checking the middle and repeatedly halving the search range. It needs sorted data and constant-time access by index for O(log n) worst-case time. An iterative implementation uses O(1) extra space.
- The comparison order must match the array's sort order.
- After each comparison, discard the half that cannot contain the target.
- Return -1 if the target is missing, including for an empty array.
- With duplicates, this version returns any matching index, not necessarily the first.
Pythondef binary_search(arr, target): # arr must be sorted in ascending order. low, high = 0, len(arr) - 1 while low <= high: mid = low + (high - low) // 2 if arr[mid] == target: return mid if arr[mid] < target: low = mid + 1 else: high = mid - 1 return -1What the interviewer checks: The interviewer checks whether you handle search boundaries correctly and explain the requirements and cost of binary search.
Other ways it was asked
- “What is the time complexity of binary search?”
- “What is binary search, and when can it be used?”
- “What is the binary search algorithm, and when can it be used?”
What is a linked list?
Asked in 5 of 374 interviews · last asked Sep 13 · Concept · Junior
Show answer
A linked list is a sequence of nodes, where each node stores data and a link to the next node. The nodes do not need to sit next to each other in memory. You start at the head and follow links to reach other nodes. A doubly linked list also links each node to the previous node.
- Access by position takes O(n) time because you must follow links.
- Insertion or deletion takes O(1) once you have the needed node references; finding them can take O(n).
- Links use extra memory compared with an array.
- An empty list has no data nodes; a non-circular list usually ends with a null link.
Codehead → [10] → [20] → [30] → nullWhat the interviewer checks: The interviewer checks whether you understand nodes, links, traversal, and the basic trade-offs compared with arrays.
Other ways it was asked
- “Can you explain a linked list?”
- “What is a linked list, and how does it work?”
- “How does a linked list work?”
How do BFS and DFS differ, and when would you choose BFS?
Asked in 5 of 374 interviews · last asked Oct 7 · Concept · Junior
Show answer
BFS explores nodes level by level using a queue. DFS follows one path as far as possible before backtracking, using a stack or recursion. Choose BFS to find a shortest path in an unweighted graph, find the nearest matching node, or process nodes level by level.
- BFS finds paths with the fewest edges; DFS does not guarantee this.
- Both take O(V + E) time with adjacency lists, where V counts vertices and E counts edges.
- Track visited nodes in graphs to avoid revisiting nodes and looping through cycles.
- BFS can hold many nodes on wide levels; recursive DFS risks stack overflow on deep paths.
What the interviewer checks: The interviewer checks whether you understand traversal order, data structures, and why BFS suits unweighted shortest paths.
Other ways it was asked
- “What is the difference between BFS and DFS?”
- “How are DFS and BFS different?”
- “What is the difference between depth-first search (DFS) and breadth-first search (BFS)?”
What is the difference between mutable and immutable data types, and where would you use them?
Asked in 4 of 374 interviews · last asked Oct 22 · Concept · Junior
Show answer
Mutable objects can change after they are created. Immutable objects cannot; a different value requires a different object. Use mutable types for data you update often, such as a growing list. Use immutable types for values that should stay fixed or be shared without changes, such as strings in Python.
- Changing a mutable object can affect every variable that refers to it.
- Reassigning a variable is not the same as changing its object.
- In Python, lists are mutable and strings are immutable.
- Immutable containers can still hold mutable objects; a Python tuple can contain a list.
Pythonitems = [1, 2] shared = items items.append(3) print(shared) # [1, 2, 3]: the same list changed name = "Sam" original = name name = name + "!" print(original) # Sam: the original string did not changeWhat the interviewer checks: The interviewer checks whether you understand object changes, shared references, and when to use each type.
Other ways it was asked
- “Give one example of a mutable data type and one example of an immutable data type.”
- “Give an example of a mutable and an immutable data type, and explain how you can tell the difference.”
- “What is the basic difference between a mutable data type and an immutable data type?”
What is the difference between an array and an ArrayList?
Asked in 4 of 374 interviews · last asked Oct 22 · Concept · Junior
Show answer
In Java, an array has a fixed length, while an ArrayList can grow or shrink as elements are added or removed. Arrays can hold primitive values or objects, but ArrayList holds only objects, using wrapper types for primitives. List is an interface; ArrayList is one implementation of it.
- Both provide constant-time access by index.
- Arrays use length; ArrayList uses size() to report the number of elements.
- ArrayList uses an internal array and may copy elements when it needs more capacity.
- Inserting or removing elements in the middle of an ArrayList requires shifting elements.
What the interviewer checks: The interviewer checks whether you understand size limits, supported types, and the difference between an interface and its implementation.
Other ways it was asked
- “What is the difference between ArrayList and List in Java?”
- “How is an array different from an ArrayList?”
In Java, how does an ArrayList grow internally when it runs out of capacity, and what happens to existing elements during that growth?
Asked in 4 of 374 interviews · last asked Oct 22 · Concept · Mid-level
Show answer
When an ArrayList fills up, it allocates a larger backing array and copies existing element references into it. In current OpenJDK, growth is usually about 1.5 times the old capacity. Growth does not clone objects or change their order or indices. A no-argument ArrayList starts empty and normally allocates capacity 10 on its first add.
- The exact growth policy depends on the implementation and version; Java does not guarantee a growth factor.
- A growth operation takes O(n) time because it copies existing references.
- Appending takes amortized O(1) time across many additions.
- Capacity is the backing array length; size is the number of stored elements.
What the interviewer checks: The interviewer checks whether you understand array resizing, reference copying, and the cost of appending.
Other ways it was asked
- “In Java, when an ArrayList grows past capacity, what happens to its backing storage and what does that imply for existing element references and indices?”
- “In Java, what happens internally when you add an element to an ArrayList beyond its current capacity? How is the backing array resized, and how are existing elements moved?”
- “What is the default capacity of a Java ArrayList, and how does it grow when you add more elements?”
How does Java HashMap handle collisions, and how did Java 8 change crowded buckets?
Asked in 4 of 374 interviews · last asked Oct 17 · Concept · Mid-level
Show answer
HashMap stores colliding entries in the same bucket and uses hash values and equals() to find keys. Buckets normally use linked lists. Java 8 added red-black trees for crowded buckets, with a treeification threshold of 8 and a minimum table capacity of 64. Below that capacity, HashMap grows the table instead.
- In OpenJDK's put path, adding a ninth bucket entry can trigger treeification.
- Tree lookup is usually O(log n), but same-hash, non-comparable keys can still require O(n).
- Equal keys replace values; different keys can share a bucket.
What the interviewer checks: The interviewer checks whether you understand collisions, key equality, and when HashMap uses trees instead of lists.
Other ways it was asked
- “How did HashMap improve collision handling after Java 8?”
- “What changed in HashMap collision handling after Java 8?”
- “In Java, explain how HashMap handles collisions internally, and what changes when a bucket gets treeified.”
What is recursion?
Asked in 4 of 374 interviews · last asked Oct 6 · Concept · Junior
Show answer
Recursion is when a function calls itself to solve a smaller version of the same problem. A base case stops the calls. Each call must move toward that base case, and its result returns to the previous call.
- The base case handles a simple input without another recursive call.
- The recursive case reduces the problem and calls the function again.
- Recursive calls usually use stack space; too many calls can cause a stack overflow.
Pythondef factorial(n): if n < 0: raise ValueError("n must be nonnegative") if n == 0: return 1 return n * factorial(n - 1) print(factorial(4)) # 24What the interviewer checks: The interviewer checks whether you understand self-calls, base cases, and why recursion stops.
Other ways it was asked
- “Can you explain recursion?”
- “Can you explain to me how recursion works?”
- “What is recursion, and how does it work?”
Design and implement an LRU cache with O(1) get and put operations.
Asked in 4 of 374 interviews · last asked Sep 10 · Write code · Mid-level
Show answer
I use a hash map and a doubly linked list for average O(1) get and put operations. Each successful get or put moves the key to the most recently used end. When capacity is exceeded, I remove the least recently used key. Python's OrderedDict provides this structure.
- Hash map operations take O(1) time on average; cache space is O(capacity).
- A missing key returns -1 and does not change the cache.
- Updating an existing key changes its value and recency without increasing the cache size.
- A cache with zero capacity stores no entries.
Pythonfrom collections import OrderedDict class LRUCache: def __init__(self, capacity): self.capacity, self.items = max(0, capacity), OrderedDict() def get(self, key): if key not in self.items: return -1 self.items.move_to_end(key); return self.items[key] def put(self, key, value): self.items[key] = value; self.items.move_to_end(key) if len(self.items) > self.capacity: self.items.popitem(last=False)What the interviewer checks: The interviewer checks whether you can combine fast lookup with recency tracking and handle updates and eviction correctly.
Other ways it was asked
- “How would you design and implement an LRU cache?”
- “Design and implement an LRU cache with get(key) and put(key, value) operations.”
- “Design an LRU cache with get(key) and put(key, value) operations that run in O(1) time.”
Write a Python program to check whether a number is prime.
Asked in 3 of 374 interviews · last asked Oct 17 · Write code · Junior
Show answer
Check whether the integer has a divisor between 2 and its square root. Numbers below 2 are not prime. If no divisor is found, the number is prime.
- Negative numbers, 0, and 1 are not prime.
- 2 is prime; all other even numbers are not.
- Check through the square root, including it, to catch perfect squares.
- Trial division takes O(√n) time and O(1) extra space.
Pythonfrom math import isqrt def is_prime(n): if n < 2: return False if n % 2 == 0: return n == 2 for divisor in range(3, isqrt(n) + 1, 2): if n % divisor == 0: return False return True print(is_prime(int(input())))What the interviewer checks: The interviewer is checking correct edge cases and whether you avoid testing divisors beyond the square root.
Other ways it was asked
- “Write Python code to determine whether a number is prime.”
DSA basics and time complexity interview questions
Start with questions about algorithms, data structures, types, loops, simple number programs, Big-O notation, and time and space use. 84 questions.
Write a function that prints “even” if a number x is even, or “odd” otherwise.
Asked in 2 of 374 interviews · last asked Aug 21 · Write code · Junior
Other ways it was asked
- “Write a program that prints "even" if a number x is even, otherwise prints "odd".”
Write a program to find and print prime numbers in a given range.
Asked in 2 of 374 interviews · last asked Sep 28 · Write code · Junior
Other ways it was asked
- “Can you write a Java program for finding prime numbers?”
- “What approach would you use to find and print all prime numbers between 1 and 51?”
- “Can you walk me through a dry run of an algorithm that prints all prime numbers between 1 and 51?”
What is an algorithm?
Asked in 2 of 374 interviews · last asked Apr 4 · Concept · Junior
Write a program to find a factorial.
Asked in 2 of 374 interviews · last asked Sep 18 · Write code · Junior
Other ways it was asked
- “Write a basic program to find the factorial of a number.”
What is a data structure?
Asked in 2 of 374 interviews · last asked Sep 7 · Concept · Junior
What is the Fibonacci series?
Asked in 2 of 374 interviews · last asked Sep 13 · Concept · Junior
Other ways it was asked
- “Explain the Fibonacci sequence.”
Where should we use a for loop?
Asked in 2 of 374 interviews · last asked Aug 12 · Concept · Junior
Other ways it was asked
- “What is a for loop?”
What is Big-O notation?
Asked in 2 of 374 interviews · last asked Aug 20 · Concept · Junior
Other ways it was asked
- “What's the purpose of Big O notation, and what does it describe about an algorithm?”
How would you estimate the runtime complexity of an algorithm?
Asked once · last asked Jul 22 · Write code · Mid-level
Are array elements homogeneous, meaning that every element must have the same type, such as integers or characters?
Asked once · last asked Mar 31 · Concept · Junior
How do you reason about time and space complexity in JavaScript, and how does that influence your choice of data structures when writing code?
Asked once · last asked May 15 · Concept · Senior
Implement a two-player game of rock, paper, scissors: take each player's move as input and report whether there is a winner and who won.
Asked once · last asked Jun 9 · Write code · Junior
Array and string interview questions
Array and string questions cover scans, two pointers, sliding windows, prefix sums, frequency counts, and edge cases. 155 questions.
Find the longest substring without repeated characters.
Asked in 3 of 374 interviews · last asked Oct 7 · Write code · Junior
Other ways it was asked
- “Given a string, find the length of the longest substring without repeating characters.”
- “How can you find the length of the longest substring without repeating characters without repeatedly scanning the substring?”
- “Find the longest substring without repeating characters. Explain your approach.”
What is an array?
Asked in 3 of 374 interviews · last asked Oct 22 · Concept · Junior
Other ways it was asked
- “What is an array in programming?”
- “Define an array.”
Find the maximum contiguous subarray sum in one pass and explain the time complexity.
Asked in 2 of 374 interviews · last asked Sep 10 · Write code · Mid-level
Other ways it was asked
- “How would you implement an algorithm to find the maximum subarray sum?”
- “How can you optimize an algorithm for finding the maximum subarray sum?”
- “How can you optimize an algorithm for finding the maximum subarray sum to run in O(n) time?”
Given existing conference room bookings as an array of start- and end-time pairs and a new meeting request in the same format, write a function that determines whether the new meeting can be booked without overlapping any existing meeting.
Asked in 2 of 374 interviews · last asked Jun 23 · Write code · Junior
Other ways it was asked
- “Given a list of existing conference-room bookings, each represented by a start time and an end time, and one new meeting request in the same format, write a function that returns true if the new meeting can be booked without overlapping any existing meeting, and false otherwise. Assume one meeting ending exactly when another starts is allowed.”
What is the three-sum problem, and how would you solve it?
Asked in 2 of 374 interviews · last asked Sep 5 · Write code · Junior
Other ways it was asked
- “How would you implement a solution to the three-sum problem?”
- “What is the 3Sum problem?”
How would you find the first non-repeating character in a string?
Asked in 2 of 374 interviews · last asked Sep 21 · Write code · Mid-level
Other ways it was asked
- “Write a function that returns the first non-repeating character in a string.”
Write Python code to count the frequency of each character in a user-provided name.
Asked in 2 of 374 interviews · last asked Sep 18 · Write code · Junior
Other ways it was asked
- “Write a Python program to count the frequency of each character in a string.”
Write code to find the second-largest element in an array without sorting.
Asked in 2 of 374 interviews · last asked Sep 18 · Write code · Mid-level
Other ways it was asked
- “How can you find the second-largest element in an array without using a sorting function?”
- “What is another approach to finding the second-largest element in an array?”
- “Find the second largest element in the array. Can you write a Python program?”
What should a maximum-subarray-sum function return when every number is negative?
Asked in 2 of 374 interviews · last asked Sep 10 · Concept · Mid-level
Other ways it was asked
- “How would you find the maximum-sum contiguous subarray when the array may contain negative numbers?”
- “What should the maximum subarray sum be when all the numbers are negative?”
- “If the array contains only negative numbers, such as [-5, -2, -8], what should the function return?”
Can an array contain values of different data types?
Asked in 2 of 374 interviews · last asked Aug 27 · Concept · Junior
Other ways it was asked
- “Can an array store values of any type?”
What is a palindrome?
Asked in 2 of 374 interviews · last asked Oct 5 · Concept · Junior
What is the two-pointer approach?
Asked in 2 of 374 interviews · last asked Sep 10 · Concept · Junior
Other ways it was asked
- “How does the two-pointer technique work, and when would you use it?”
Linked list, stack and queue interview questions
Compare linked lists, stacks, and queues through memory layouts, pointer operations, bracket checking, and expression evaluation. 67 questions.
Write code to check whether parentheses are valid.
Asked in 2 of 374 interviews · last asked Oct 20 · Write code · Junior
Other ways it was asked
- “What test cases would you write to ensure a function that checks whether parentheses are valid, including nested parentheses, is correct and robust?”
- “How would you structure a function that checks whether parentheses are valid, and what should it do when it encounters a closing bracket that does not match the expected type?”
How does an algorithm reverse a linked list?
Asked in 2 of 374 interviews · last asked Sep 3 · Concept · Junior
Other ways it was asked
- “How would you reverse a linked list?”
Can you explain the difference between a stack and a queue, and give a real-world example of each?
Asked in 2 of 374 interviews · last asked Aug 14 · Concept · Junior
Other ways it was asked
- “What's the difference between a stack and a queue, and when would you choose each?”
How do Python lists differ from arrays in whether they can hold values of different types?
Asked once · last asked Mar 31 · Concept · Junior
Other ways it was asked
- “Why can Python lists contain values of different types?”
In a stack, what is the difference between peek and pop?
Asked once · last asked Apr 9 · Concept · Junior
Given a pile of cards represented as strings, implement a shuffle that moves the top card to a second pile, then repeatedly places subsequent cards alternately under and on top of the second pile until the first pile is empty.
Asked once · last asked Apr 13 · Write code · Junior
Other ways it was asked
- “Given an initial pile of cards represented as strings, how would you implement this shuffle: move the top card to a second pile, then repeatedly place the next card alternately under and on top of the second pile until the first pile is empty?”
In what situations would you create a custom iterator?
Asked once · last asked May 25 · Concept · Mid-level
What are the benefits of using an ArrayList instead of a linked list for searching, and how would you justify that choice?
Asked once · last asked Nov 17 · Concept · Junior
How is a LinkedList implemented internally in Java?
Asked once · last asked Jul 16 · Concept · Mid-level
Could you implement a stack in Java?
Asked once · last asked Aug 5 · Write code · Junior
How can you implement a queue using an array, and what are its strengths and limitations?
Asked once · last asked Aug 10 · Concept · Junior
Given an array of strings representing a valid arithmetic expression in Reverse Polish notation, evaluate the expression and return the result. The operands may be integers or results of other operations; the operators are addition, subtraction, multiplication, and division, with integer division truncating toward zero.
Asked once · last asked Aug 11 · Write code · Junior
Hash map and set interview questions
Explore how maps and sets handle hashing, collisions, resizing, key equality, lookups, and duplicate removal. 116 questions.
Remove duplicates from a list while preserving the original order.
Asked in 3 of 374 interviews · last asked Sep 24 · Write code · Junior
Other ways it was asked
- “How would you evaluate logic intended to return unique elements in a vector while preserving their original order?”
- “How would you fix logic that should return unique elements in a vector while preserving their original order?”
- “How would you test that C++ logic returns unique elements in a vector while preserving their original order?”
How do a HashMap and a HashSet differ, and when would you use each?
Asked in 3 of 374 interviews · last asked Sep 22 · Concept · Junior
Other ways it was asked
- “What is the difference between a HashMap and a HashSet?”
- “When would you use a Set instead of a Map?”
- “When can a problem be solved with a Set instead of a Map, and how would you choose between them?”
Find the length of the longest consecutive sequence in an unsorted array in O(n) time.
Asked in 3 of 374 interviews · last asked Sep 18 · Write code · Mid-level
Other ways it was asked
- “Design a function that takes a list of integers and returns the length of the longest consecutive sequence in the list.”
- “Given an array of integers, find the length of the longest consecutive sequence.”
- “Given an unsorted array of integers, return the length of the longest consecutive-element sequence. Aim for O(N) time. How would you approach it, and what edge cases would you consider?”
What is the difference between a List, a Set, and a Map?
Asked in 2 of 374 interviews · last asked Sep 17 · Concept · Junior
Other ways it was asked
- “What is the difference between List, Set, and Map in Apex?”
In a HashMap, what exactly happens during a resize or rehash, how are buckets redistributed, and what determines which bucket an existing entry moves to?
Asked in 2 of 374 interviews · last asked Oct 17 · Concept · Senior
Other ways it was asked
- “In Java, what happens during HashMap resizing and rehashing? How are entries redistributed across the new table without recomputing every hash from scratch?”
In Java, explain the contract between equals and hashCode, and what can go wrong in a HashMap if it's violated.
Asked in 2 of 374 interviews · last asked Oct 17 · Concept · Mid-level
Other ways it was asked
- “What contract exists between `equals` and `hashCode`, and what problem occurs if it is violated in a `HashMap`?”
What do you understand by hashing in Java?
Asked in 2 of 374 interviews · last asked Sep 16 · Concept · Junior
Other ways it was asked
- “What is hashing in Java?”
What is a dictionary?
Asked in 2 of 374 interviews · last asked Oct 18 · Concept · Junior
Group an array of strings into anagram groups using a hash map.
Asked once · last asked Sep 8 · Write code · Junior
Other ways it was asked
- “How would you group anagrams in an array of strings?”
- “How would you group anagrams without sorting each string?”
- “How would you use a hash map to group strings that are anagrams?”
How would you read drug aliases and choose a data structure to store them in?
Asked once · last asked Jul 24 · Write code · Mid-level
Other ways it was asked
- “How would you design a data structure to store drug aliases?”
Where is a hash code used, and in which data structures?
Asked once · last asked Jan 28 · Concept · Mid-level
If two separate instances of a C# class have identical property values and are used as dictionary keys, will the dictionary store one entry or two?
Asked once · last asked Jan 28 · Concept · Mid-level
Other ways it was asked
- “If two separate instances of a C# class have identical property values, will a dictionary store one entry or two?”
Searching and sorting interview questions
These questions cover binary search, sorting algorithms, comparators, ordering requirements, and performance trade-offs. 53 questions.
What sorting algorithms are you familiar with?
Asked in 3 of 374 interviews · last asked Aug 26 · Concept · Junior
Other ways it was asked
- “What other sorting algorithms do you know?”
- “What sorting algorithms are you aware of?”
What is the time complexity of insertion sort?
Asked in 3 of 374 interviews · last asked Aug 27 · Concept · Junior
Other ways it was asked
- “What is the time complexity of sorting an array?”
- “What is the time complexity of heap sort?”
- “What is the time complexity of bubble sort?”
Write a C++ program that takes 15 random numbers, sorts them, and prints them.
Asked in 2 of 374 interviews · last asked Aug 12 · Write code · Junior
Other ways it was asked
- “Write a C++ program that generates 10 random numbers, sorts them in ascending order, and prints them.”
- “Write a C++ program that stores 15 random names in an array, sorts them alphabetically, and prints them.”
- “Write a Java program that takes 15 random numbers, sorts them, and prints them.”
How would you use a comparator to sort an array, what is a comparator, and what is the time complexity?
Asked once · last asked Apr 8 · Write code · Junior
Given a sorted array that has been rotated, how would you find the index of a target value in O(log n)?
Asked once · last asked Apr 11 · Write code · Junior
Can you write a binary search implementation in JavaScript?
Asked once · last asked Jun 24 · Write code · Junior
Which data structure would you choose to search for a number: an array, a linked list, or an ArrayList?
Asked once · last asked Nov 17 · Concept · Junior
Why is it mandatory for data to be ordered before running a binary search? What failures occur if the collection is unsorted?
Asked once · last asked Aug 10 · Concept · Junior
How would you break down the performance gap between quicksort’s best-case and worst-case scenarios? What data patterns cause that variance?
Asked once · last asked Aug 10 · Concept · Junior
How would you sort an array of objects by salary?
Asked once · last asked Aug 10 · Write code · Junior
Given an array of distinct integers sorted in ascending order and a target integer, implement a function to search for the target in the array. Return its index if it exists; otherwise, return -1.
Asked once · last asked Aug 11 · Write code · Junior
Can you create me a C++ program that takes in 10 random names, alphabetizes them, and prints them on the screen?
Asked once · last asked Aug 12 · Write code · Junior
Tree, graph and heap interview questions
Tree, graph, and heap questions cover representations, traversals, database indexes, shortest paths, connectivity, cycles, and path problems. 93 questions.
What is Dijkstra's algorithm, and when is it used?
Asked in 3 of 374 interviews · last asked Oct 9 · Concept · Junior
Other ways it was asked
- “Can you explain the Dijkstra algorithm?”
- “What is the Dijkstra algorithm?”
Explain the A* algorithm for calculating the shortest path.
Asked in 2 of 374 interviews · last asked Oct 9 · Concept · Junior
Other ways it was asked
- “Can you explain the A* algorithm?”
Which data structure is commonly used for indexing in a database management system?
Asked in 2 of 374 interviews · last asked Aug 27 · Concept · Junior
Other ways it was asked
- “What data structures are commonly used to implement database indexes?”
What is a binary search tree?
Asked in 2 of 374 interviews · last asked Sep 30 · Concept · Junior
What algorithmic approach would you use to find the longest consecutive sequence along a root-to-leaf path in a tree?
Asked once · last asked Sep 15 · Write code · Mid-level
Other ways it was asked
- “What is the time complexity of an algorithm for finding the longest consecutive sequence along a root-to-leaf path in a tree?”
- “How would you solve the same problem when given a tree, finding the longest consecutive sequence along any path from the root to a leaf?”
- “How would you solve the problem of finding the longest consecutive sequence along a root-to-leaf path in a tree?”
How would you implement hierarchical folder traversal in Power Apps or Power Automate?
Asked once · last asked Jun 9 · Tooling · Mid-level
Other ways it was asked
- “How would you implement hierarchical folder traversal in Power Automate?”
Given an array of integers, how would you convert it into a min heap?
Asked once · last asked Jul 27 · Concept · Junior
Other ways it was asked
- “Please explain the process of converting an array of integers into a min heap.”
In the binary-tree maximum path sum problem, what counts as a path, and how should the solution handle a tree whose node values are all negative?
Asked once · last asked Sep 10 · Concept · Mid-level
Other ways it was asked
- “How should a binary-tree maximum path sum solution handle an all-negative tree or an empty tree?”
- “How should a binary-tree maximum path sum algorithm handle a negative contribution from a child node?”
What is the difference between a graph and a tree?
Asked once · last asked Jan 27 · Concept · Junior
When modeling a problem as a graph, what should the vertices and edges represent?
Asked once · last asked Jan 27 · Concept · Mid-level
What is a B-tree index, and how does it work?
Asked once · last asked Feb 23 · Concept · Mid-level
Implement logic to traverse the hierarchical folder structure, check each folder for files, and print the name of every folder that contains files.
Asked once · last asked Jun 9 · Write code · Mid-level
Recursion, dynamic programming and greedy interview questions
Test your understanding of recursion, divide and conquer, dynamic programming, greedy choices, backtracking, and optimization problems. 57 questions.
Explain what dynamic programming is.
Asked in 3 of 374 interviews · last asked Oct 9 · Concept · Junior
Other ways it was asked
- “What do you know about dynamic programming?”
- “Why is dynamic programming useful, and when would you use it?”
Give a problem suited to a greedy algorithm and explain why local choices produce an optimal solution.
Asked in 3 of 374 interviews · last asked Sep 4 · Concept · Junior
Other ways it was asked
- “Can you provide a specific example where a greedy algorithm is effectively used?”
- “Describe a problem where a greedy algorithm is appropriate. What makes choosing the best local option at each step effective?”
- “Can you give an example of a problem suited to a greedy approach and explain why?”
Why use dynamic programming for coin change, and how does it compare with recursive search?
Asked in 2 of 374 interviews · last asked Sep 15 · Concept · Mid-level
Other ways it was asked
- “What is the significance of dynamic programming in solving the coin change problem as compared to a greedy approach?”
- “Can you elaborate on how dynamic programming ensures finding the optimal solution in the coin change problem?”
- “Why is dynamic programming appropriate for the coin-change problem, and what other approaches could you use?”
Can you write a Python program to demonstrate dynamic programming?
Asked in 2 of 374 interviews · last asked Jul 17 · Write code · Mid-level
Other ways it was asked
- “Give an example code that demonstrates dynamic programming in Python.”
How could you systematically explore smaller subsets while checking that no selected elements are consecutive and no pair sums to 13?
Asked once · last asked Jun 6 · Scenario · Junior
Other ways it was asked
- “How would you build a valid subset incrementally while ensuring that no selected elements are consecutive and no pair sums to 13?”
- “How could you diagram possible subsets to check that no two selected elements are consecutive and no pair sums to 13?”
How would you solve the N-Queens problem using reinforcement learning?
Asked once · last asked Aug 13 · Scenario · Mid-level
How would you solve the longest palindromic subsequence problem using dynamic programming?
Asked once · last asked Aug 22 · Write code · Mid-level
How would your integer-to-Roman-numeral conversion algorithm handle 700?
Asked once · last asked Aug 31 · Write code · Junior
Other ways it was asked
- “How can an integer-to-Roman-numeral conversion algorithm handle values such as 3, 7, 4, and 9 without mapping every possible value individually?”
- “How should an integer-to-Roman-numeral algorithm handle values that are multiples of 4 or 9, such as 40, 90, 400, and 900?”
- “How would you handle 700 when converting integers to Roman numerals if your base values are 3, 7, 4, and 9?”
Given the conditions of no consecutive elements and no pairs summing to 13, what patterns or smaller cases do you notice that could help simplify the problem?
Asked once · last asked Jun 6 · Scenario · Junior
How could you use examples with four or five numbers to test your approach to selecting a subset with no consecutive elements and no pair summing to 13?
Asked once · last asked Jun 6 · Scenario · Junior
Other ways it was asked
- “What assumptions would you make when selecting a subset with no consecutive elements and no pair summing to 13, and how could testing them refine your approach?”
Write a Python code example demonstrating a divide-and-conquer algorithm.
Asked once · last asked Jul 17 · Write code · Junior
Other ways it was asked
- “Write a Python code example demonstrating the divide-and-conquer algorithm.”
Write a Python function that flattens a nested dictionary into a flat format using dot-separated keys.
Asked once · last asked Jul 24 · Write code · Mid-level
Algorithm design and optimization interview questions
Apply algorithm choices to caches, rate limiters, search features, large datasets, scheduling, routing, distributed systems, and project performance. 88 questions.
Given that some cache responses are large, and recently used or recently added entries tend to be used again soon, what cache eviction approach makes sense?
Asked once · last asked Jul 27 · Scenario · Mid-level
Other ways it was asked
- “Given limited cache capacity, some large responses, and a pattern where recently used or added entries are likely to be used again soon, what cache eviction approach would you use to keep good performance?”
What are the time and space complexities of the `allow` operation in a rolling-window rate limiter?
Asked once · last asked Sep 6 · Concept · Mid-level
Other ways it was asked
- “Why is the `allow` operation in a rolling-window rate limiter amortized O(1), and what are its time and space complexities?”
How would you detect conflicting robot paths and use that information to optimize traffic?
Asked once · last asked Sep 25 · Design · Senior
Other ways it was asked
- “How would you detect conflicting robot paths in a traffic-control service?”
How would you prevent one robot from waiting a long time for another robot to complete its entire route?
Asked once · last asked Sep 25 · Scenario · Senior
Other ways it was asked
- “How would you prevent one robot from waiting until another robot completes its entire route?”
What data structure ensures fairness in checkout processing, and how do we prevent the payment system from overloading?
Asked once · last asked Oct 6 · Design · Mid-level
Other ways it was asked
- “What data structure would you use to ensure fair first-come-first-served processing for checkout payments while preventing the payment system from being overloaded?”
How would you modify an API client to retrieve an account's complete transaction history rather than just one time range?
Asked once · last asked Mar 5 · Scenario · Mid-level
When retrieving transaction history in batches while moving backward through time, should an empty batch stop further requests?
Asked once · last asked Mar 5 · Scenario · Mid-level
If an account's opening date is unavailable, how would you retrieve its transaction history?
Asked once · last asked Mar 5 · Scenario · Mid-level
How would you optimize transaction-history retrieval if the system has been running for 20 years but the account is only one year old?
Asked once · last asked Mar 5 · Scenario · Senior
Implement a thread-safe in-memory cache storing companies with names and candidates with passport numbers and scores; generate unique integer company IDs, support company lookup by ID, efficiently find all candidates by passport number, and update a candidate's score within a specified company.
Asked once · last asked Mar 6 · Write code · Senior
Other ways it was asked
- “Implement a thread-safe in-memory cache for recruiting companies. Each company has a name and candidates, and each candidate has a passport number and score. Generate a unique integer ID when storing a company, support lookup by ID, index candidates by passport number, and allow a candidate's score to be updated within a specified company.”
How would you design passport-number lookups and candidate score updates to avoid searching every company?
Asked once · last asked Mar 6 · Design · Senior
How would you design a thread-safe collection structure for a company-and-candidate cache, and what should a passport-number index map to to support future updates?
Asked once · last asked Mar 6 · Design · Senior
Compiler, math and logic puzzle interview questions
Questions here cover compilation, parsing, tokenization, state machines, numerical methods, mathematical reasoning, formal proofs, and logic puzzles. 59 questions.
What is the difference between a compiler and an interpreter?
Asked in 3 of 374 interviews · last asked Oct 18 · Concept · Junior
Show answer
A compiler translates code into another form, such as machine code or bytecode, for execution. An interpreter runs code by processing its instructions at runtime. Both can work together: CPython compiles Python source to bytecode, then runs that bytecode in its interpreter.
- Compilation does not always produce machine code.
- Interpreters do not necessarily execute source code one line at a time.
- Some systems also compile code during execution, called just-in-time compilation.
What the interviewer checks: The interviewer checks whether you understand translation versus execution and how both can work together.
Other ways it was asked
- “What is the difference between a compiler and an interpreter when executing Python?”
- “What is a compiler and an interpreter?”
What is an annotated parse tree?
Asked in 2 of 374 interviews · last asked Mar 27 · Concept · Junior
Other ways it was asked
- “What is the difference between a parse tree and an annotated parse tree, and what is a parse tree?”
- “What is a parse tree?”
What are the phases of a compiler?
Asked in 2 of 374 interviews · last asked Mar 27 · Concept · Junior
Do Gauss's variation equations always allow larger time steps, or can they become numerically unstable?
Asked once · last asked Apr 15 · Concept · Senior
Other ways it was asked
- “What other conditions can make Gauss's variation equations numerically unstable?”
If q(x) = k(x-a)(x-b)(x-c) and p(x) = q(x) + 7, what is the general form of p(x)?
Asked once · last asked Jul 21 · Concept · Junior
Other ways it was asked
- “If q(x) = p(x) - 7 and q(x) = k(x-a)(x-b)(x-c), what condition must hold at x = d for q(d) to equal 3?”
- “For q(x) = k(x-a)(x-b)(x-c), what must k(d-a)(d-b)(d-c) equal for q(d) to equal 3?”
- “If q(x) = k(x-a)(x-b)(x-c) and p(x) = q(x) + 7, does the factor k change when forming p(x)?”
What are LLVM and MLIR, and how are they used in compiler development?
Asked once · last asked Aug 12 · Concept · Senior
You have 16 memory sticks in a server and one is faulty. How would you locate it with the fewest iterations?
Asked once · last asked Feb 3 · Scenario · Mid-level
What is the difference between top-down and bottom-up parsing?
Asked once · last asked Mar 27 · Concept · Junior
Other ways it was asked
- “When would you use top-down versus bottom-up parsing in a real-time application?”
In what cases would the condition that the time derivative of the relative distance is zero fail to identify the time of closest approach?
Asked once · last asked Apr 15 · Scenario · Senior
When would you choose analytical rather than numerical propagation, or vice versa, and what are the forces and trade-offs involved?
Asked once · last asked Apr 15 · Concept · Senior
Why use an adaptive step size rather than a fixed one, and in what situations would you use each?
Asked once · last asked Apr 15 · Concept · Mid-level
How would adaptive versus fixed step sizes affect orbit propagation in near-Earth orbit and GEO?
Asked once · last asked Apr 15 · Scenario · Senior
Live coding round next? Coding mode in the MeetAssist desktop app solves the problem on your screen, with your phone as the remote.
Related interview questions
- Software Engineer interview questions
- AI Engineer interview questions
- QA Engineer interview questions
- Data Scientist interview questions
- Data Engineer interview questions
- OOP and Design Patterns interview questions
- System Design interview questions
- Microservices interview questions
- REST API interview questions
- Kafka and Message Queues interview questions
- Caching and Redis interview questions
- Operating Systems interview questions
- Computer Networks interview questions
- Git interview questions
How this list is made
Every question here was asked by a real interviewer in a real job interview that a candidate ran MeetAssist in. After the call, the interviewer's questions are pulled from the transcript. Practice sessions, tests, exams and anything that was not a job interview are dropped.
Questions are rewritten so they make sense on their own: names of people, employers and clients are removed, and speech-to-text mistakes are fixed. Small talk, logistics and questions about one candidate's own résumé are left out. Rephrasings of the same question are merged, and the count is the number of different interviews it came up in.
The interviews come from candidates who use MeetAssist, so they lean towards software, data and AI roles: the shares describe these interviews, not every Data Structures and Algorithms interview. Answers to the most asked questions are written and checked by an editor; a "common mistake" is shown only when reviews of real answers in these interviews show it, with the count.
374 interviews, 269 candidates, Sep 2025 to Oct 2026. Updated every month with new interviews.
Or add the Chrome extension