Amazon OA Format & Strategy
Amazon OA Structure
| Section | Questions | Time | Focus |
|---|---|---|---|
| Coding | 2 problems | 70 min | Arrays, Strings, HashMap, Trees |
| Debugging | 7-9 code snippets | 20 min | Find and fix bugs |
| Work Style | 25-35 MCQ | 15-20 min | Amazon Leadership Principles |
Time Management Strategy
Coding Section (70 minutes):
- Problem 1 (Easy/Medium): 20-25 minutes
- Problem 2 (Medium/Hard): 25-30 minutes
- Buffer time: 10-15 minutes for edge cases and testing
Debugging Section (20 minutes):
- ~2 minutes per snippet
- Don't spend more than 3 minutes on any single bug
- Common bugs: off-by-one, null checks, boundary conditions
Java Templates for OA
// Fast I/O for large inputs
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
// Read integer
int n = Integer.parseInt(br.readLine().trim());
// Read array from space-separated line
int[] arr = Arrays.stream(br.readLine().split(" "))
.mapToInt(Integer::parseInt)
.toArray();
// Common utility methods
public static int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
public static long modPow(long base, long exp, long mod) {
long result = 1;
base %= mod;
while (exp > 0) {
if ((exp & 1) == 1) result = result * base % mod;
base = base * base % mod;
exp >>= 1;
}
return result;
}
Common OA Problem Types
- Array/String Manipulation: Rotate array, string compression, anagram checking
- HashMap Problems: Two sum variations, frequency counting, group anagrams
- Tree Problems: BST validation, level order traversal, path sum
- Greedy/Interval: Meeting rooms, task scheduling, jump game
- Prefix Sum/Subarray: Range queries, subarray sums, difference arrays
- Matrix Problems: Island counting, rotation, spiral order
Debugging Section Strategies
Common Bug Categories
1. Off-by-One Errors
// Bug: Wrong loop boundary
for (int i = 0; i <= arr.length; i++) { // Should be < not <=
System.out.println(arr[i]);
}
// Fix:
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
2. Null Pointer Exceptions
// Bug: Missing null check
public int getLength(String s) {
return s.length(); // s could be null
}
// Fix:
public int getLength(String s) {
if (s == null) return 0;
return s.length();
}
3. Integer Overflow
// Bug: Overflow in multiplication
int product = a * b; // May overflow for large values
// Fix:
long product = (long) a * b;
// Or use BigInteger for very large numbers
4. Array Index Issues
// Bug: Wrong index calculation
int mid = (low + high) / 2; // Can overflow
// Fix:
int mid = low + (high - low) / 2;
5. Missing Edge Cases
// Bug: Empty input not handled
public int findMax(int[] arr) {
int max = arr[0]; // Crashes if arr is empty
for (int i = 1; i < arr.length; i++) {
max = Math.max(max, arr[i]);
}
return max;
}
// Fix:
public int findMax(int[] arr) {
if (arr == null || arr.length == 0) throw new IllegalArgumentException("Empty array");
int max = arr[0];
for (int i = 1; i < arr.length; i++) {
max = Math.max(max, arr[i]);
}
return max;
}
6. Incorrect Return Values
// Bug: Returns wrong value for edge case
public boolean isPalindrome(String s) {
int left = 0, right = s.length() - 1;
while (left < right) {
if (s.charAt(left) != s.charAt(right)) return false;
left++;
right--;
}
return false; // Should be true!
}
// Fix: return true at the end
Quick Debug Checklist
- Check loop boundaries (
<vs<=) - Look for null checks on objects/arrays
- Verify return values for edge cases
- Check for integer overflow in arithmetic
- Validate array index ranges
- Ensure proper variable initialization
Practice Problems
Given an integer array nums, rotate the array to the right by k steps, where k is non-negative. This is a classic OA-style problem that tests array manipulation skills.
Example:
Input: nums = [1,2,3,4,5,6,7], k = 3
Output: [5,6,7,1,2,3,4]
Rotate right by 3: [1,2,3,4,5,6,7] -> [7,1,2,3,4,5,6] -> [6,7,1,2,3,4,5] -> [5,6,7,1,2,3,4]
Brute Force Solution — O(n * k) time, O(1) space
Rotate one by one k times
class Solution {
public void rotate(int[] nums, int k) {
for (int i = 0; i < k; i++) {
int last = nums[nums.length - 1];
for (int j = nums.length - 1; j > 0; j--) {
nums[j] = nums[j - 1];
}
nums[0] = last;
}
}
}Optimal Solution — O(n) time, O(1) space
Three reverses technique
class Solution {
public void rotate(int[] nums, int k) {
int n = nums.length;
k = k % n;
reverse(nums, 0, n - 1);
reverse(nums, 0, k - 1);
reverse(nums, k, n - 1);
}
private void reverse(int[] nums, int start, int end) {
while (start < end) {
int temp = nums[start];
nums[start] = nums[end];
nums[end] = temp;
start++;
end--;
}
}
}Edge Cases:
- k = 0 (no rotation needed)
- k = nums.length (full rotation, no change)
- k > nums.length (need modulo)
- Single element array
- All elements same
Quiz
1. In Amazon OA, how much time should you ideally spend on the first (easier) coding problem?
2. What is the most common type of bug to look for in the debugging section?
3. What is the primary purpose of Online Assessment (OA) Prep?
4. What is a common mistake when implementing Online Assessment (OA) Prep?
Flashcards
Question
What is the time split for Amazon OA coding section?
Click to reveal answer
Answer
70 minutes total: 20-25 min for Problem 1, 25-30 min for Problem 2, 10-15 min buffer for testing
Question
What are the 5 most common bug categories in OA debugging?
Click to reveal answer
Answer
Off-by-one, null pointer, integer overflow, array index issues, incorrect return values
Question
What is Online Assessment (OA) Prep?
Click to reveal answer
Answer
Online Assessment (OA) Prep is a key concept in software engineering.
Question
When to use Online Assessment (OA) Prep?
Click to reveal answer
Answer
Use Online Assessment (OA) Prep when building production systems that require reliability, scalability, and maintainability.
Question
Online Assessment (OA) Prep best practices
Click to reveal answer
Answer
Follow SOLID principles, write clean code, test thoroughly, document decisions, and monitor in production.
Revision Notes
Key Takeaways
- 1.Practice under timed conditions - 35 minutes per problem maximum
- 2.Master 5-6 core patterns that cover 80% of OA problems
- 3.For debugging, start with loop boundaries and null checks
- 4.Don't get stuck - move on and come back if time permits
Interview Tips
- •Read the entire problem before starting to code
- •Write test cases first to understand the problem better
- •If stuck on Problem 2, ensure Problem 1 is perfect first
- •For debugging, systematically check from top to bottom of the code
Cheat Sheet
OA Prep Cheat Sheet
Amazon OA Format:
- 2 Coding Problems: 70 min
- 7-9 Debugging Snippets: 20 min
- 25-35 Work Style MCQ: 15-20 min
Time Management:
- Problem 1: 20-25 min
- Problem 2: 25-30 min
- Buffer: 10-15 min
- Debugging: ~2 min per snippet
Fast I/O Template:
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
Quick Debug Checklist:
- Loop boundaries (< vs <=)
- Null checks
- Return values for edge cases
- Integer overflow
- Array index ranges