← Amazon Interview Insights

Amazon·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Amazon coding screen for a software engineer role. One question, path traversal on a nested structure, seemed straightforward until I actually had to handle the mixed dot-and-bracket notation cleanly.

Questions Asked (1)

Q1

Implement a function get(object, path) that retrieves a value from an arbitrarily nested structure of maps and arrays, where the path string uses dot notation for keys and bracket notation for array indices (e.g. "a.b[1].c.d[2][13]").

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

My first instinct was to split on dots and call it a day, which obviously breaks the moment you hit a bracket.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the input structure and path syntax, then outline a parsing strategy that tokenizes the path into keys and indices. Implement the traversal iteratively or recursively, handling edge cases like missing keys, out-of-bounds indices, and invalid paths. Discuss trade-offs between simplicity and robustness, and consider performance implications for large structures.

Pro tip: Demonstrate production readiness by discussing how to handle edge cases gracefully (e.g., returning undefined instead of throwing) and mentioning potential security concerns like prototype pollution when accessing arbitrary paths.

1. Clarify requirements and assumptions

Ask questions to confirm the data types (maps vs objects, arrays), path syntax rules, and expected behavior for missing paths or invalid inputs. This shows attention to detail and avoids ambiguity.

2. Design the path parser

Explain how to tokenize the path string into an array of keys and indices, handling dot notation and bracket notation, including multiple indices like [2][13].

3. Implement the traversal logic

Describe iterating over the tokens, accessing each level of the structure, and handling both object properties and array indices. Consider iterative vs recursive approaches and their trade-offs.

4. Handle edge cases and errors

Discuss how to handle missing keys, out-of-bounds indices, null/undefined values, and invalid path formats. Decide whether to return undefined, throw, or use a default value.

5. Analyze complexity and optimizations

Mention time and space complexity (O(n) where n is path length), and potential optimizations like caching parsed paths or using a compiled accessor for repeated calls.

Key Points to Mention

  • Path parsing: splitting on dots and extracting bracket indices, handling edge cases like consecutive brackets or empty segments.
  • Traversal: iterating through tokens, checking existence at each step, and accessing properties/indices safely.
  • Error handling: returning undefined for missing paths, throwing for invalid input, or using a default value.
  • Security: avoiding prototype pollution by not allowing access to __proto__ or constructor.
  • Performance: O(n) time complexity, and potential optimizations for repeated access.
  • Testing: covering nested structures, arrays, missing keys, and malformed paths.

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