PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Google

Implement string formatting and request tracking tasks

Last updated: May 21, 2026

Quick Overview

This multi-part question evaluates string manipulation, numeric formatting, character-mapping validation under 180° rotation, and event-tracking/order management competencies, assessing parsing, edge-case handling, mapping validation, and design of data structures for ordered output.

  • easy
  • Google
  • Coding & Algorithms
  • Software Engineer

Implement string formatting and request tracking tasks

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

You are given several small coding tasks. Implement each as described. ## Task A — Convert `snake_case` to `camelCase` Write a function that converts an identifier from `snake_case` to `camelCase`. - Input: a string `s` containing lowercase letters `a-z` and underscores `_`. - Output: the camelCase version. - Rules/edge cases: - Consecutive underscores should be treated as a single word separator (ignore empty parts). - If `s` starts/ends with underscores, ignore those underscores. - The first word remains lowercase; each subsequent word is capitalized. Example: - `"hello_world" -> "helloWorld"` - `"__my__var__name_" -> "myVarName"` ## Task B — Format an integer with thousands separators Write a function that formats a (possibly negative) integer with commas as thousands separators. - Input: an integer `n` (may be large; assume it fits in 64-bit signed integer). - Output: a string representation using commas every 3 digits from the right. Examples: - `123 -> "123"` - `1234 -> "1,234"` - `-12345678 -> "-12,345,678"` ## Task C — Validate an OCR string under 180° rotation An OCR system outputs a string `t` that may contain digits and a few letters. You need to decide whether it can represent an integer between **1 and 200 inclusive** under either normal reading or after a **180-degree rotation**. Define a rotation mapping `rot(c)` for characters; rotation is valid only if every character in the string has a mapping. Rotating a whole string means: 1) reverse the string, and 2) replace each character `c` with `rot(c)`. Return `true` if either: - `t` as-is is a valid base-10 integer in `[1, 200]`, OR - `rotate180(t)` is a valid base-10 integer in `[1, 200]`. Assume the rotation map is provided as a dictionary (examples from the interview note included): - `'6' <-> '9'` - plus any additional pairs given at runtime (e.g., `'h' -> '4'`, `'L' -> '7'`). Characters not in the map are invalid for rotation. Examples (assuming map includes `6<->9`, `0->0`, `1->1`, `8->8`): - `"69"` rotates to `"69"` and is valid (`69` in range) -> `true` - `"201"` is out of range, rotate may or may not help -> depends on mapping -> compute ## Task D — Track request begin/end times and print in a required order You are implementing a `Server` class that receives events for requests. Each request has a unique `requestId`. You must implement two methods: - `begin(requestId, timestamp)` - `end(requestId, timestamp)` ### Part 1 Whenever both timestamps for a request are known, print/log a line: - `requestId begin=<beginTs> end=<endTs>` Assumptions: - Events may arrive out of order (an `end` can arrive before `begin`). - There may be multiple in-flight requests. ### Follow-up Instead of printing immediately when a pair is complete, the server must always print **completed requests in increasing order of end time** (earliest `end` printed first). If multiple have the same end time, break ties by `requestId`. Design the data structures and logic to support this ordering efficiently.

Quick Answer: This multi-part question evaluates string manipulation, numeric formatting, character-mapping validation under 180° rotation, and event-tracking/order management competencies, assessing parsing, edge-case handling, mapping validation, and design of data structures for ordered output.

Related Interview Questions

  • Find Containing Range - Google (medium)
  • Rearrange Tasks With Cooldown - Google (medium)
  • Solve Three Array and Matrix Path Problems - Google (medium)
  • Consolidate On-Call Rotation Segments - Google (medium)
  • Solve Flower Placement and Directory Deletion - Google (medium)
Google logo
Google
Feb 11, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
11
0
Loading...

You are given several small coding tasks. Implement each as described.

Task A — Convert snake_case to camelCase

Write a function that converts an identifier from snake_case to camelCase.

  • Input: a string s containing lowercase letters a-z and underscores _ .
  • Output: the camelCase version.
  • Rules/edge cases:
    • Consecutive underscores should be treated as a single word separator (ignore empty parts).
    • If s starts/ends with underscores, ignore those underscores.
    • The first word remains lowercase; each subsequent word is capitalized.

Example:

  • "hello_world" -> "helloWorld"
  • "__my__var__name_" -> "myVarName"

Task B — Format an integer with thousands separators

Write a function that formats a (possibly negative) integer with commas as thousands separators.

  • Input: an integer n (may be large; assume it fits in 64-bit signed integer).
  • Output: a string representation using commas every 3 digits from the right.

Examples:

  • 123 -> "123"
  • 1234 -> "1,234"
  • -12345678 -> "-12,345,678"

Task C — Validate an OCR string under 180° rotation

An OCR system outputs a string t that may contain digits and a few letters. You need to decide whether it can represent an integer between 1 and 200 inclusive under either normal reading or after a 180-degree rotation.

Define a rotation mapping rot(c) for characters; rotation is valid only if every character in the string has a mapping. Rotating a whole string means:

  1. reverse the string, and
  2. replace each character c with rot(c) .

Return true if either:

  • t as-is is a valid base-10 integer in [1, 200] , OR
  • rotate180(t) is a valid base-10 integer in [1, 200] .

Assume the rotation map is provided as a dictionary (examples from the interview note included):

  • '6' <-> '9'
  • plus any additional pairs given at runtime (e.g., 'h' -> '4' , 'L' -> '7' ). Characters not in the map are invalid for rotation.

Examples (assuming map includes 6<->9, 0->0, 1->1, 8->8):

  • "69" rotates to "69" and is valid ( 69 in range) -> true
  • "201" is out of range, rotate may or may not help -> depends on mapping -> compute

Task D — Track request begin/end times and print in a required order

You are implementing a Server class that receives events for requests. Each request has a unique requestId.

You must implement two methods:

  • begin(requestId, timestamp)
  • end(requestId, timestamp)

Part 1

Whenever both timestamps for a request are known, print/log a line:

  • requestId begin=<beginTs> end=<endTs>

Assumptions:

  • Events may arrive out of order (an end can arrive before begin ).
  • There may be multiple in-flight requests.

Follow-up

Instead of printing immediately when a pair is complete, the server must always print completed requests in increasing order of end time (earliest end printed first). If multiple have the same end time, break ties by requestId.

Design the data structures and logic to support this ordering efficiently.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

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