PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates skills in string parsing and bracket balancing, CSV/file parsing and joining, computation of derived values, and sorting, emphasizing data representation, correctness, and algorithmic efficiency.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Solve delimiter and CSV tasks

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

The interview included two coding tasks: 1. **Validate bracket sequences.** Given a string consisting only of the characters `(`, `)`, `[`, `]`, `{`, and `}`, determine whether the brackets are balanced and properly nested. 2. **Join two CSV files and sort by speed.** You are given two CSV files with the following headers: ```text NAME,LEG_LENGTH,DIET ``` and ```text NAME,STRIKE,STANCE ``` For each dinosaur name that appears in both files, compute `SPEED = some_function(LEG_LENGTH, STRIKE)`, where `some_function` is provided. Output each dinosaur's name together with its computed speed, sorted by speed in descending order.

Quick Answer: This question evaluates skills in string parsing and bracket balancing, CSV/file parsing and joining, computation of derived values, and sorting, emphasizing data representation, correctness, and algorithmic efficiency.

Part 1: Validate Bracket Sequences

Given a string `s` consisting only of the characters `(`, `)`, `[`, `]`, `{`, and `}`, determine whether the bracket sequence is balanced and properly nested. A sequence is valid if every opening bracket is closed by the same type of bracket, and brackets close in the correct order.

Constraints

  • 0 <= len(s) <= 100000
  • Each character in `s` is one of: `(`, `)`, `[`, `]`, `{`, `}`

Examples

Input: '()[]{}'

Expected Output: True

Explanation: Each opening bracket has a matching closing bracket in the correct order.

Input: '([{}])'

Expected Output: True

Explanation: This is a properly nested sequence.

Input: '(]'

Expected Output: False

Explanation: The closing `]` does not match the opening `(`.

Input: '([)]'

Expected Output: False

Explanation: The counts match, but the nesting order is wrong.

Input: ''

Expected Output: True

Explanation: An empty string is considered balanced.

Hints

  1. Use a stack to remember opening brackets as you scan from left to right.
  2. When you see a closing bracket, it must match the most recent unmatched opening bracket.

Part 2: Join Two CSV Files and Sort by Speed

You are given the contents of two CSV files as strings. The first file has header `NAME,LEG_LENGTH,DIET` and the second has header `NAME,STRIKE,STANCE`. For each dinosaur name that appears in both files, compute `SPEED = round(LEG_LENGTH * STRIKE, 2)`. Return a list of `[NAME, SPEED]` pairs sorted by speed in descending order. If two dinosaurs have the same speed, sort those ties by name in ascending alphabetical order. Ignore the `DIET` and `STANCE` columns. Rows may contain extra surrounding spaces, and blank lines should be ignored.

Constraints

  • 0 <= number of data rows in each file <= 10000
  • Each file includes its header row
  • Names are unique within each file
  • Numeric fields are valid non-negative decimal numbers
  • Field values do not contain embedded commas

Examples

Input: ['NAME,LEG_LENGTH,DIET\nRex,2.0,carnivore\nAva,1.5,herbivore\nMoe,3.0,omnivore', 'NAME,STRIKE,STANCE\nAva,4.0,biped\nRex,3.0,biped\nNotInFirst,10.0,biped']

Expected Output: [['Ava', 6.0], ['Rex', 6.0]]

Explanation: Only `Ava` and `Rex` appear in both files. Both have speed 6.0, so the tie is broken alphabetically.

Input: ['NAME,LEG_LENGTH,DIET\nA,1.0,herbivore', 'NAME,STRIKE,STANCE\nB,2.0,biped']

Expected Output: []

Explanation: There are no shared names between the two files.

Input: ['NAME,LEG_LENGTH,DIET', 'NAME,STRIKE,STANCE']

Expected Output: []

Explanation: Both files contain only headers, so there is nothing to join.

Input: ['NAME,LEG_LENGTH,DIET\nStego,4.0,herbivore', 'NAME,STRIKE,STANCE\nStego,2.5,quadruped']

Expected Output: [['Stego', 10.0]]

Explanation: A single shared dinosaur gives one output row.

Input: ['NAME,LEG_LENGTH,DIET\n\n Neo , 2.5 , herbivore \nTri,1.0,carnivore', 'NAME,STRIKE,STANCE\nTri,4.0,biped\n\n Neo , 2.0 , biped ']

Expected Output: [['Neo', 5.0], ['Tri', 4.0]]

Explanation: Extra spaces and blank lines should be ignored while parsing.

Hints

  1. Parse one file into a dictionary keyed by dinosaur name so you can join in O(1) average lookup time.
  2. After building the joined result, sort with a key like `(-speed, name)`.
Last updated: Apr 19, 2026

Loading coding console...

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.

Related Coding Questions

  • Find Shortest Unique Prefixes - Meta (medium)
  • Compute Exclusive Execution Times - Meta (medium)
  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)