Skip to content
advancedPhase 8 · Interview Prep

Amazon Online Assessment

Prepare for Amazon's OA with timed practice and common patterns.

2h
8 problems
Topic Progress0%

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

  1. Array/String Manipulation: Rotate array, string compression, anagram checking
  2. HashMap Problems: Two sum variations, frequency counting, group anagrams
  3. Tree Problems: BST validation, level order traversal, path sum
  4. Greedy/Interval: Meeting rooms, task scheduling, jump game
  5. Prefix Sum/Subarray: Range queries, subarray sums, difference arrays
  6. 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

  1. Check loop boundaries (< vs <=)
  2. Look for null checks on objects/arrays
  3. Verify return values for edge cases
  4. Check for integer overflow in arithmetic
  5. Validate array index ranges
  6. Ensure proper variable initialization

Practice Problems

0/1solved
Rotate Array
Array Manipulation

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?

Question 1 options

2. What is the most common type of bug to look for in the debugging section?

Question 2 options

3. What is the primary purpose of Online Assessment (OA) Prep?

Question 3 options

4. What is a common mistake when implementing Online Assessment (OA) Prep?

Question 4 options

Flashcards

Question

What is the time split for Amazon OA coding section?

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?

Answer

Off-by-one, null pointer, integer overflow, array index issues, incorrect return values

Question

What is Online Assessment (OA) Prep?

Answer

Online Assessment (OA) Prep is a key concept in software engineering.

Question

When to use Online Assessment (OA) Prep?

Answer

Use Online Assessment (OA) Prep when building production systems that require reliability, scalability, and maintainability.

Question

Online Assessment (OA) Prep best practices

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:

  1. Loop boundaries (< vs <=)
  2. Null checks
  3. Return values for edge cases
  4. Integer overflow
  5. Array index ranges