PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Meta

Solve Parser, Trading, Tree, And Deck Tasks

Last updated: May 19, 2026

Quick Overview

This question evaluates input validation and parsing for numeric literals, array-based algorithmic optimization for single-trade profit, tree traversal for extracting rightmost nodes per depth, and software design for a stateful card-deck with shuffle and testing.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Solve Parser, Trading, Tree, And Deck Tasks

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You will solve several independent programming tasks. For each task, implement clean, tested code and state the time and space complexity. 1. Validate a numeric literal Given a string `s`, return whether it represents a valid decimal number. After trimming leading and trailing spaces, the entire string must match this grammar: - `number := sign? (digits '.' digits? | '.' digits | digits) exponent?` - `exponent := ('e' | 'E') sign? digits` - `sign := '+' | '-'` - `digits := one or more characters from '0' to '9'` Examples that should be valid: `"0"`, `"-3.14"`, `"+.8"`, `"2e10"`, `"-1.2E-3"`. Examples that should be invalid: `"abc"`, `"1a"`, `"e9"`, `"."`, `"+"`, `"1e"`, `"--6"`. 2. Maximize profit from one trade Given an array `prices` where `prices[i]` is the price of an asset on day `i`, choose at most one buy day and one later sell day. Return the maximum possible profit. If no profitable trade exists, return `0`. 3. Return the rightmost value at each tree depth Given the root of a binary tree, return the list of node values visible when viewing the tree from the right side. For each depth, include the value of the rightmost node at that depth. 4. Implement a card deck Design and implement a small card-deck library for a standard 52-card deck. Include representations for suits and ranks, and implement operations such as `reset`, `shuffle`, `draw(n)`, and `remaining`. The deck must not produce duplicate cards before reset, and `draw(n)` should define clear behavior when fewer than `n` cards remain. Include unit tests for normal and edge cases.

Quick Answer: This question evaluates input validation and parsing for numeric literals, array-based algorithmic optimization for single-trade profit, tree traversal for extracting rightmost nodes per depth, and software design for a stateful card-deck with shuffle and testing.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
Meta logo
Meta
Apr 9, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
0
0

You will solve several independent programming tasks. For each task, implement clean, tested code and state the time and space complexity.

  1. Validate a numeric literal

Given a string s, return whether it represents a valid decimal number. After trimming leading and trailing spaces, the entire string must match this grammar:

  • number := sign? (digits '.' digits? | '.' digits | digits) exponent?
  • exponent := ('e' | 'E') sign? digits
  • sign := '+' | '-'
  • digits := one or more characters from '0' to '9'

Examples that should be valid: "0", "-3.14", "+.8", "2e10", "-1.2E-3". Examples that should be invalid: "abc", "1a", "e9", ".", "+", "1e", "--6".

  1. Maximize profit from one trade

Given an array prices where prices[i] is the price of an asset on day i, choose at most one buy day and one later sell day. Return the maximum possible profit. If no profitable trade exists, return 0.

  1. Return the rightmost value at each tree depth

Given the root of a binary tree, return the list of node values visible when viewing the tree from the right side. For each depth, include the value of the rightmost node at that depth.

  1. Implement a card deck

Design and implement a small card-deck library for a standard 52-card deck. Include representations for suits and ranks, and implement operations such as reset, shuffle, draw(n), and remaining. The deck must not produce duplicate cards before reset, and draw(n) should define clear behavior when fewer than n cards remain. Include unit tests for normal and edge cases.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta 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.