PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Implement nested object path lookup

Last updated: Apr 12, 2026

Quick Overview

This question evaluates parsing and traversal of nested maps and arrays, robust error handling for missing keys and out-of-bounds indices, and reasoning about algorithmic time and space complexity.

  • medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Implement nested object path lookup

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Implement a function `get(obj, path)` for a nested data structure composed only of maps and arrays. Path rules: - `.` accesses a map key - `[i]` accesses an array index - keys do not contain `.` or brackets - example path syntax: `ab[1].c.d[2][13]` Return the value at the given path. If any key is missing, an index is out of bounds, or the path does not match the actual type at some step, return `null`. Examples: - `get({"a": {"b": [10, 20]}}, "a.b[1]") -> 20` - `get({"a": {"b": [10, 20]}}, "a.b[3]") -> null` Write the function and analyze its time and space complexity.

Quick Answer: This question evaluates parsing and traversal of nested maps and arrays, robust error handling for missing keys and out-of-bounds indices, and reasoning about algorithmic time and space complexity.

Related Interview Questions

  • Implement Datacenter Router Commands - Amazon (hard)
  • Implement Event Filtering and Queue Routing - Amazon (medium)
  • Determine if all courses can be completed - Amazon (medium)
  • Replace Delimited Tokens in a String - Amazon (medium)
  • Minimize Circular Redistribution Cost - Amazon (medium)
Amazon logo
Amazon
Oct 31, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0
Loading...

Implement a function get(obj, path) for a nested data structure composed only of maps and arrays.

Path rules:

  • . accesses a map key
  • [i] accesses an array index
  • keys do not contain . or brackets
  • example path syntax: ab[1].c.d[2][13]

Return the value at the given path. If any key is missing, an index is out of bounds, or the path does not match the actual type at some step, return null.

Examples:

  • get({"a": {"b": [10, 20]}}, "a.b[1]") -> 20
  • get({"a": {"b": [10, 20]}}, "a.b[3]") -> null

Write the function and analyze its time and space complexity.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.