FastPrepParse Indented YAML Mappings
Problems/Parse Indented YAML Mappings

Parse Indented YAML Mappings

Uber logoUber● MediumFULLTIMEPHONE SCREEN

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The source names a YAML-parser task but does not provide a grammar or output contract. This exercise uses a bounded nested-mapping subset and matches the reported parsing capability at about 70%.

Parse a valid YAML-like document yaml containing nested mappings. Each non-empty line has one of these forms:

  • key: opens a nested mapping;
  • key: value defines a scalar value.

Indentation uses exactly two spaces per level. A child line is indented one level deeper than its containing mapping; indentation may later return to any earlier open level. Keys contain only letters, digits, underscores, and hyphens, and sibling keys are unique. Scalar values are non-empty trimmed text; quotes and # have no special meaning in this subset. Empty lines are ignored.

Return one string for each scalar line in document order. Use its full dot-separated key path, followed by = and the trimmed scalar value.

Function

parseYamlMappings(yaml: String) → String[]

Examples

Example 1

yaml = "server:\n  host: api.example.com\n  port: 443\nmode: prod"return = ["server.host=api.example.com","server.port=443","mode=prod"]

The two indented scalar keys belong under server; mode returns to the root level.

Example 2

yaml = "app:\n  database:\n    host: db\n    enabled: true\n  name: demo"return = ["app.database.host=db","app.database.enabled=true","app.name=demo"]

The path stack grows through app.database and then returns one level for app.name.

Constraints

  • 1 <= yaml.length <= 2 * 10^5.
  • The document contains at most 2 * 10^4 non-empty lines.
  • The document satisfies the grammar and indentation rules stated above.

More Uber Phone Screen questions

  • Worst-Performing Ads by CTR in a Campaign TreePHONE SCREEN · Seen Nov 2026
  • Earliest Time All Users Are ConnectedPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Max Points on a LinePHONE SCREEN · Seen Oct 2026
  • Convex Function MinimizationPHONE SCREEN · Seen Oct 2026
  • Meeting Rooms IIPHONE SCREEN · Seen Oct 2026
  • Merge Meeting IntervalsPHONE SCREEN · Seen Oct 2026
  • Minimum Meeting Rooms with AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Find Robots by Blocker DistancesPHONE SCREEN · Seen Oct 2026
  • Sliding-Window Rate LimiterPHONE SCREEN · Seen Oct 2026
  • Count Connected IslandsPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Remove Parentheses from a Plus-Minus ExpressionOracle · PHONE SCREENOracle interview questions
  • Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREENRoblox interview questions
  • Decode StringCompass International Holdings · PHONE SCREENCompass International Holdings interview questions
  • Rich Text Parser Part 3 (Depth Tokens)Figma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions
  • Calculator with ParenthesesGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Decode an Encoded StringAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Decode Repeated GroupsWaymo · PHONE SCREENWaymo interview questions
  • Deserialize XML Into a TreeAdobe · PHONE SCREENAdobe interview questions
  • Convert Email Text to Structured MarkupZip · PHONE SCREEN · ONSITE INTERVIEWZip interview questions
  • Parse Variable, Expression, and Application TreesSambaNova Systems · PHONE SCREEN · ONSITE INTERVIEWSambaNova Systems interview questions
All Uber interview questionsSee Uber hiring insights
Saved
class Solution {
    public String[] parseYamlMappings(String yaml) {
        // Write your code here.
    }
}
Checking account…