Best solutions for Amazon interview tasks.
Amazon as all other companies doesn’t share information about the tasks they use during their interviewing process. But internet is full of lists of the tasks which collecting the people who participating in the interview. IMHO the most comprehensive and the most actual list is collected here. So I decided it would be nice idea to collect solutions for these task in one set of articles. I’m going to write detailed explanations for each solution how it works and why I believe it is the best. I will use C++17 programming language. Each time when I finish a new article I will change corresponding string in the table of contents to a hyperlink to the article.
Small explanation about difficulty of the tasks. As you can see each task is market like [New Grad], [Experienced] and so on. As I understand it doesn’t show difficulty of the task, it shows a level of position which was proposed by Amazon to a person who was interviewed. There are many difficult tasks marked [Intern] or [New Grad].
AMCAT is an automatic testing system from Amazon like Leetcode or HackerRank. You can do tests in AMCAT only if a recruiter from Amazon send you a special hyperlink.
Number of stars means frequency of the question on interviews.
Descriptions of the tasks from Amazon may be slightly different than the similar solutions on Leetcode or other websites. I will describe such cases I know.
You might be interested to read a similar set of articles about the best solutions for Microsoft interview tasks here and solutions for very nice set of lessons from Codility here.
Table of contents.
- Top K Frequently Mentioned Keywords ⭐⭐⭐ [Experienced]
- Zombie in Matrix (Min hours to send file to all available servers) ⭐⭐⭐ [Experienced]
- Critical Routers ⭐⭐ [New Grad | Experienced]
- Product Suggestions ⭐⭐ [New Grad | Experienced]
- Number of Clusters ⭐⭐ [Experienced]
- Reorder Data in Log Files [Experienced]
- Optimal Utilization [Experienced]
- Min Cost to Connect Ropes / Min Time to Merge Files [Experienced]
- Treasure Island / Min Distance to Remove the Obstacle (BFS) [Experienced]
- Treasure Island II
- Find Pair With Given Sum ⭐⭐ [Experienced, Intern]
- Copy List with Random Pointer ⭐⭐ [New Grad]
- Merge Two Sorted Lists ⭐⭐ [New Grad | Intern]
- Subtree of Another Tree ⭐⭐ [New Grad]
- Search a 2D Matrix II ⭐⭐ [New Grad]
- Critical Connections ⭐ [New Grad]
- Favorite Genres ⭐⭐ [New Grad]
- Two Sum — Unique Pairs ⭐⭐ [New Grad]
- Spiral Matrix ⭐ [New Grad]
- Count substrings with exactly K distinct chars ⭐ [Intern]
- Max Of Min Altitudes ⭐⭐ [Intern]
- Longest Palindromic Substring ⭐⭐ [Intern]
- Substrings of size K with K distinct chars ⭐⭐ [Intern]
- Most Common Word ⭐⭐ [Intern]
- K Closest Points to Origin ⭐ [Intern]
- Generate Parentheses ⭐ [Intern]
- Min Cost to Connect All Nodes (a.k.a. Min Cost to Add New Roads)
- Min Cost to Repair Edges (MST)
- Prison Cells After N Days
- Partition Labels
- Subtree with Maximum Average
- Load Balancer [Experienced]
- Point of Lattice ⭐ [Experienced]
- Merge Intervals ⭐
- Roll Dice ⭐
- Longest string without 3 consecutive characters
- Longest string made up of only vowels
- https://leetcode.com/problems/number-of-dice-rolls-with-target-sum/ [Intern]
- Nth GP [Intern]