Coding rounds
Amazon coding rounds
5 timed coding challenges drawn from real loops. Submit a solution to see your test pass rate and AI feedback.
Valid Parentheses
Given a string `s` containing only the characters `()[]{}`, determine if the input string is valid. Brackets must close in the correct order and every opening bracket has a matching closing bracket of the same type. Use a stack.
Open
Top K Frequent Elements
Given an integer array `nums` and an integer `k`, return the `k` most frequent elements. You may return the answer in any order. Aim for better than O(n log n) using bucket sort by frequency.
Open
Rotting Oranges
In an `m x n` grid each cell is 0 (empty), 1 (fresh orange), or 2 (rotten orange). Every minute, any fresh orange adjacent (4-directionally) to a rotten one becomes rotten. Return the minimum minutes until no fresh orange remains, or -1 if impossible. Multi-source BFS.
Open
Course Schedule
There are `numCourses` labeled 0..numCourses-1. `prerequisites[i] = [a, b]` means you must take course `b` before course `a`. Return true if you can finish all courses. Detect a cycle in the dependency graph (topological sort / Kahn’s algorithm).
Open
K Closest Points to Origin
Given an array of `points` where `points[i] = [x, y]` and an integer `k`, return the `k` closest points to the origin (0, 0) by Euclidean distance. The answer may be in any order. Discuss the heap (O(n log k)) and quickselect (O(n) avg) approaches.
Open