PracHub
QuestionsPremiumLearningGuidesCheatsheetNEW

Quick Overview

This problem set evaluates practical coding competencies including string parsing and sign handling, positional and frequency-based matching for feedback scoring, grid pathfinding via backtracking traversal, and binary-tree vertical ordering using column indices and level-order traversal, testing data structure knowledge (arrays, hash maps, trees) and algorithmic techniques (search, traversal, and counting). It is commonly asked in the Coding & Algorithms domain to measure correctness on edge cases, handling of duplicates and positional constraints, and implementation efficiency; the tasks are primarily practical implementation problems that also require conceptual understanding of algorithmic trade-offs and traversal strategies.

  • medium
  • Bloomberg
  • Coding & Algorithms
  • Software Engineer

Solve common string/tree/grid interview tasks

Company: Bloomberg

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

### Problem Set (solve all in one interview) #### 1) Parse an integer from a string ("atoi"-style) Implement a function: - `parseInt(s: string) -> int` Given a string `s` representing a base-10 integer, return its integer value. **Assumptions (make explicit during interview):** - `s` may contain an optional leading `+` or `-`. - `s` contains only digits after the optional sign (no decimals). - If the format is invalid, you may either return `0` or throw/return an error value (state your choice). **Examples** - `"123" -> 123` - `"-45" -> -45` --- #### 2) Compute Wordle-style feedback for a guess Implement a function: - `scoreWordle(guess: string, target: string) -> string` Both strings have the same length `n`. Return a result string of length `n` where each position indicates: - `G` (green): `guess[i] == target[i]` - `Y` (yellow): `guess[i]` occurs in `target` but **not** at position `i`, and the occurrence is not already “used up” by other matches (i.e., handle duplicates correctly) - `B` (black/gray): the letter does not occur in the remaining unused letters of `target` **Example** - `guess = "allee", target = "apple" -> "GYBYB"` --- #### 3) Word path in a grid Given an `m x n` grid of characters `board` and a string `word`, determine if `word` can be formed by a path in the grid. Rules: - You may move up/down/left/right. - You cannot use the same cell more than once in the same path. Return `true` if the word exists, else `false`. --- #### 4) Vertical order traversal of a binary tree Given the root of a binary tree, return its vertical order traversal: - Group nodes by their **column index** (root at column `0`, left child `-1`, right child `+1`). - Output columns from leftmost to rightmost. - Within the same column, list nodes from top to bottom; if two nodes share the same row and column, order them left-to-right as encountered in a level-order traversal. Return a list of columns, e.g. `[[col-2 nodes], [col-1 nodes], ..., [col+2 nodes]]`.

Quick Answer: This problem set evaluates practical coding competencies including string parsing and sign handling, positional and frequency-based matching for feedback scoring, grid pathfinding via backtracking traversal, and binary-tree vertical ordering using column indices and level-order traversal, testing data structure knowledge (arrays, hash maps, trees) and algorithmic techniques (search, traversal, and counting). It is commonly asked in the Coding & Algorithms domain to measure correctness on edge cases, handling of duplicates and positional constraints, and implementation efficiency; the tasks are primarily practical implementation problems that also require conceptual understanding of algorithmic trade-offs and traversal strategies.

Part 1: Parse an Integer from a String

Implement a function solution(s) that converts a base-10 integer string into its integer value. The string may start with an optional '+' or '-' sign. After the optional sign, every remaining character must be a digit. For this problem, return 0 if the format is invalid.

Constraints

  • 0 <= len(s) <= 100000
  • s may begin with '+' or '-'
  • If a sign is present, it must be followed by at least one digit
  • No whitespace or decimal points need to be handled
  • Use normal Python integer behavior; no 32-bit clamping is required

Examples

Input: '123'

Expected Output: 123

Explanation: A normal positive integer should be parsed directly.

Input: '-45'

Expected Output: -45

Explanation: The leading '-' makes the result negative.

Input: '+0'

Expected Output: 0

Explanation: A leading '+' is allowed.

Input: ''

Expected Output: 0

Explanation: Empty input is invalid, so return 0.

Input: '12a3'

Expected Output: 0

Explanation: Any non-digit after the optional sign makes the format invalid.

Hints

  1. Handle the optional sign first, then scan the rest of the characters from left to right.
  2. Build the number manually using value = value * 10 + digit instead of calling int().

Part 2: Compute Wordle-Style Feedback

Implement a function solution(guess, target) that returns Wordle-style feedback for a guess against a target word. Both strings should have the same length. For each position, return 'G' if the letters match exactly, 'Y' if the guessed letter appears elsewhere in the unused part of the target, and 'B' otherwise. Duplicate letters must be handled correctly. If the lengths differ, return an empty string.

Constraints

  • 0 <= len(guess) == len(target) <= 100000 in valid inputs
  • Strings may contain repeated characters
  • A target character can only be matched once: first by greens, then by yellows

Examples

Input: ('apple', 'apple')

Expected Output: 'GGGGG'

Explanation: Every character matches in the same position.

Input: ('allee', 'apple')

Expected Output: 'GYBBG'

Explanation: The first 'a' and last 'e' are green; only one of the two 'l' letters can be yellow.

Input: ('bbbb', 'aaaa')

Expected Output: 'BBBB'

Explanation: No guessed letters appear in the target.

Input: ('aabb', 'bbaa')

Expected Output: 'YYYY'

Explanation: All letters exist, but every one is in the wrong position.

Hints

  1. A good strategy is to do two passes: mark all greens first, then process yellows using counts of the remaining target letters.
  2. Do not mark a letter yellow just because it exists somewhere in the target; make sure that occurrence has not already been used.

Part 3: Word Path in a Grid

Given a rectangular grid of characters and a word, determine whether the word can be formed by a path in the grid. You may move up, down, left, or right, and you may not reuse the same cell in a single path. Return True if the word exists, otherwise return False.

Constraints

  • 0 <= number of rows, columns <= 6
  • 0 <= len(word) <= 15
  • board is rectangular
  • You may move only in 4 directions: up, down, left, right
  • A cell may be used at most once in any single candidate path

Examples

Input: ([['A','B','C','E'],['S','F','C','S'],['A','D','E','E']], 'ABCCED')

Expected Output: True

Explanation: A valid path exists through adjacent cells without reusing any cell.

Input: ([['A','B','C','E'],['S','F','C','S'],['A','D','E','E']], 'SEE')

Expected Output: True

Explanation: The word can be formed using a different path in the same board.

Input: ([['A','B','C','E'],['S','F','C','S'],['A','D','E','E']], 'ABCB')

Expected Output: False

Explanation: The board contains the letters, but forming the word would require reusing a cell.

Input: ([], 'A')

Expected Output: False

Explanation: A non-empty word cannot be formed from an empty board.

Input: ([['A']], '')

Expected Output: True

Explanation: The empty word is considered trivially present.

Hints

  1. Try starting a depth-first search from each cell that matches the first character.
  2. Mark a cell as visited while exploring a path, then unmark it when backtracking.

Part 4: Vertical Order Traversal of a Binary Tree

You are given a binary tree in level-order list form, where None represents a missing child. Return the vertical order traversal of the tree. The root is at column 0, the left child of a node is at column -1, and the right child is at column +1. Output columns from leftmost to rightmost. Within the same column, nodes should appear from top to bottom, and if two nodes share the same row and column, they must be ordered left to right as encountered in level-order traversal.

Constraints

  • 0 <= len(values) <= 10000
  • values contains integers or None
  • The list represents the tree in standard level-order form
  • If values is empty or starts with None, the tree is empty

Examples

Input: [3, 9, 20, None, None, 15, 7]

Expected Output: [[9], [3, 15], [20], [7]]

Explanation: Nodes are grouped by column from left to right.

Input: [3, 9, 8, 4, 0, 1, 7]

Expected Output: [[4], [9], [3, 0, 1], [8], [7]]

Explanation: The nodes 0 and 1 share the same row and column, and BFS keeps them in left-to-right order.

Input: []

Expected Output: []

Explanation: An empty tree has no columns.

Input: [1, None, 2, 3]

Expected Output: [[1, 3], [2]]

Explanation: The node 3 is the left child of 2, so it returns to column 0.

Hints

  1. Use a breadth-first traversal and track each node's column index.
  2. BFS naturally preserves the required top-down and left-to-right order for nodes that share a row and column.
Last updated: May 13, 2026

Loading coding console...

PracHub

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

Related Coding Questions

  • Solve meeting and tree problems - Bloomberg (easy)
  • Minimize travel cost with two cities - Bloomberg (easy)
  • Check connectivity between two subway stations - Bloomberg (easy)
  • Design a data structure for dynamic top‑K frequency - Bloomberg (hard)
  • Find tree root and bucket numbers - Bloomberg (hard)