PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Cortex

Parse API JSON and print org chart

Last updated: Mar 29, 2026

Quick Overview

This question evaluates HTTP and JSON parsing, CSV processing, hierarchical data modeling, sorting, and algorithmic efficiency for building and printing an organizational chart.

  • medium
  • Cortex
  • Coding & Algorithms
  • Software Engineer

Parse API JSON and print org chart

Company: Cortex

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You will solve two practical coding tasks. ## Task 1: Call an HTTP API and parse JSON You are given an HTTP endpoint that returns JSON describing transit stops. ### API response format Assume the response body is valid JSON shaped like: ```json { "stops": [ {"id": "123", "name": "South Station", "description": "Commuter rail hub"}, {"id": "456", "name": "Park Street", "description": "Red/Green lines"} ] } ``` ### Requirements - Make a GET request to the endpoint. - Parse the JSON and extract, for each stop: - `name` - `description` (may be missing or empty) - Print one line per stop in the format: ``` <name> - <description> ``` ### Follow-ups (discussion) - What changes would you make to turn this into production-quality code (error handling, retries/timeouts, logging/metrics, schema changes, pagination, testing, etc.)? --- ## Task 2: Build an org chart from CSV You are given a CSV file where each row contains: ``` employee_name,title,department,manager_name ``` - `manager_name` is empty for the top-level leader. - Each employee has at most one manager. ### Goal Print the organization structure so that each manager appears before their reports. ### Output format Print one employee per line with **2 spaces of indentation per level**: - Level 0: top-level leader - Level 1: direct reports - Level 2: reports of level-1 employees - etc. ### Ordering For each manager, print their direct reports in **lexicographic order by `employee_name`**. ### Example Input rows (order in file is arbitrary): ``` Alice,CEO,Executive, Bob,CFO,Finance,Alice Carol,Analyst,Finance,Bob Dave,Intern,Finance,Carol Eve,COO,Operations,Alice Frank,CTO,Engineering,Alice ``` Expected output: ``` Alice Bob Carol Dave Eve Frank ``` ### Constraints / assumptions - The input contains no cycles. - Every non-empty `manager_name` refers to an employee present in the file. - The file can be large enough that an O(n^2) approach may time out; aim for near O(n log n) or better (excluding sorting within report lists).

Quick Answer: This question evaluates HTTP and JSON parsing, CSV processing, hierarchical data modeling, sorting, and algorithmic efficiency for building and printing an organizational chart.

Cortex logo
Cortex
Dec 8, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
4
0

You will solve two practical coding tasks.

Task 1: Call an HTTP API and parse JSON

You are given an HTTP endpoint that returns JSON describing transit stops.

API response format

Assume the response body is valid JSON shaped like:

{
  "stops": [
    {"id": "123", "name": "South Station", "description": "Commuter rail hub"},
    {"id": "456", "name": "Park Street", "description": "Red/Green lines"}
  ]
}

Requirements

  • Make a GET request to the endpoint.
  • Parse the JSON and extract, for each stop:
    • name
    • description (may be missing or empty)
  • Print one line per stop in the format:
<name> - <description>

Follow-ups (discussion)

  • What changes would you make to turn this into production-quality code (error handling, retries/timeouts, logging/metrics, schema changes, pagination, testing, etc.)?

Task 2: Build an org chart from CSV

You are given a CSV file where each row contains:

employee_name,title,department,manager_name
  • manager_name is empty for the top-level leader.
  • Each employee has at most one manager.

Goal

Print the organization structure so that each manager appears before their reports.

Output format

Print one employee per line with 2 spaces of indentation per level:

  • Level 0: top-level leader
  • Level 1: direct reports
  • Level 2: reports of level-1 employees
  • etc.

Ordering

For each manager, print their direct reports in lexicographic order by employee_name.

Example

Input rows (order in file is arbitrary):

Alice,CEO,Executive,
Bob,CFO,Finance,Alice
Carol,Analyst,Finance,Bob
Dave,Intern,Finance,Carol
Eve,COO,Operations,Alice
Frank,CTO,Engineering,Alice

Expected output:

Alice
  Bob
    Carol
      Dave
  Eve
  Frank

Constraints / assumptions

  • The input contains no cycles.
  • Every non-empty manager_name refers to an employee present in the file.
  • The file can be large enough that an O(n^2) approach may time out; aim for near O(n log n) or better (excluding sorting within report lists).

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

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

Master your tech interviews with 8,500+ 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.