Mercury Coding Interview Questions
25 Mercury coding interview problems with full optimal solutions — 11 easy, 11 medium, 3 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an Mercury interviewer values, and a FAQ section.
- #1easyfoundational
1. Two Sum
Find indices of two numbers in an array that add up to a target.
- #2easyfoundational
2. Valid Parentheses
Determine if a string of brackets is validly nested and matched.
- #3easyfoundational
3. Merge Two Sorted Lists
Merge two sorted linked lists into one sorted list by splicing nodes.
- #4easyfoundational
4. Remove Duplicates from Sorted Array
Remove duplicates in-place from a sorted array and return new length.
- #5easyfoundational
5. Remove Element
Remove all occurrences of a value from an array in-place.
- #6easyfoundational
6. Same Tree
Check whether two binary trees are structurally identical and hold equal node values.
- #7easyfoundational
7. Symmetric Tree
Determine if a binary tree is a mirror of itself around its center.
- #8easyfoundational
8. Maximum Depth of Binary Tree
Compute the maximum depth (longest root-to-leaf path) of a binary tree.
- #9easyfoundational
9. Best Time to Buy and Sell Stock
Find the maximum profit from a single buy-then-sell pair in a price series.
- #10easyfoundational
10. Single Number
Find the one element that appears exactly once where every other element appears twice.
- #11easyfoundational
11. Linked List Cycle
Detect whether a linked list contains a cycle.
- #12mediumfoundational
12. Binary Tree Level Order Traversal
Return a binary tree's nodes grouped by level from top to bottom.
- #13mediumfoundational
13. Validate Binary Search Tree
Check that a binary tree obeys the BST ordering property.
- #14mediumfoundational
14. LRU Cache
Design a cache with O(1) get and put that evicts the least recently used entry on overflow.
- #15mediumfoundational
15. Group Anagrams
Group strings into buckets where each bucket contains anagrams of each other.
- #16mediumfoundational
16. Longest Substring Without Repeating Characters
Find the length of the longest substring of a string with all distinct characters.
- #17mediumfoundational
17. 3Sum
Find all unique triplets in an array that sum to zero.
- #18mediumfoundational
18. Container With Most Water
Pick two lines that, together with the x-axis, contain the largest amount of water.
- #20mediumfoundational
20. Coin Change
Compute the fewest coins needed to make a target amount from given denominations.
- #21mediumfoundational
21. Number of Islands
Count the number of disjoint islands of '1's in a 2D grid.
- #22mediumfoundational
22. Course Schedule
Determine if all courses can be finished given a list of prerequisites.
- #24mediumfoundational
24. Top K Frequent Elements
Return the k most frequent elements from an integer array.
- #27hardfoundational
27. Median of Two Sorted Arrays
Find the median of two sorted arrays in logarithmic time.
- #28hardfoundational
28. Trapping Rain Water
Given an elevation map, compute how much rain water is trapped between the bars.
- #29hardfoundational
29. Merge k Sorted Lists
Merge k sorted linked lists into a single sorted list efficiently.