← Amazon Interview Insights

Amazon·Software Engineer·Technical Phone Screen·Junior

Junior
Apr 2026

Summary

Amazon SWE coding question, pretty basic on the surface but they layered on follow-ups that made me think twice about my initial approach.

Questions Asked (1)

Q1

Given a list of integers, print every odd number. Follow-ups: how does your solution handle negative numbers, and what if some values exceed 32-bit integer range?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I jumped straight to the modulo check and felt good about it, but the negative number follow-up tripped me up for a second.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem and constraints, then present a simple solution using the modulo operator to check for odd numbers. Address the follow-ups by explaining how negative numbers are handled (e.g., -3 % 2 == -1, so check != 0) and how to handle values beyond 32-bit range by using appropriate data types or libraries.

Pro tip: Mention that in languages like Python, integers are arbitrary precision, so no special handling is needed, but in Java/C++ you'd need BigInteger or long long. This shows awareness of language-specific trade-offs.

1. Clarify requirements

Ask about input format, output format, and constraints (e.g., list size, integer range). Confirm whether the list can be empty or contain duplicates.

2. Outline basic solution

Describe iterating through the list and checking if each number is odd using modulo 2. For positive numbers, n % 2 == 1; for negatives, n % 2 != 0 works in most languages.

3. Address negative numbers

Explain that in languages like C++/Java, -3 % 2 yields -1, so checking != 0 correctly identifies odd negatives. Alternatively, use bitwise AND (n & 1) which works for negatives in two's complement.

4. Handle large integers

Discuss that if values exceed 32-bit range, use 64-bit integers (long long) or arbitrary-precision types (BigInteger in Java, Python int). Mention potential overflow if not careful.

5. Analyze complexity and edge cases

State time complexity O(n) and space O(1) excluding output. Mention edge cases: empty list, all even, all odd, zero (even), and minimum negative value.

Key Points to Mention

  • Modulo operator behavior with negative numbers varies by language; use n % 2 != 0 for odd check.
  • Bitwise AND (n & 1) can be used for odd check and works for negative numbers in two's complement.
  • For large integers, choose appropriate data type: long long, BigInteger, or Python's int.
  • Time complexity O(n), space O(1) for the check, but output storage may be O(n).
  • Edge cases: zero is even, empty list, and potential overflow when handling large numbers.
  • Language-specific considerations: Python handles big ints natively, Java requires BigInteger, C++ may need boost or custom.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.