PracHub
QuestionsPremiumLearningGuidesCheatsheetNEW
|Home/Coding & Algorithms/Bloomberg

Solve Stack Decoding and Fuel-Constrained Paths

Last updated: May 5, 2026

Quick Overview

This prompt evaluates proficiency in parsing and string manipulation for nested repeated-pattern decoding and in graph search and state-space modeling for fuel-constrained shortest paths.

  • hard
  • Bloomberg
  • Coding & Algorithms
  • Software Engineer

Solve Stack Decoding and Fuel-Constrained Paths

Company: Bloomberg

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given two independent coding tasks. ### Task 1: Decode a Repeated-Pattern String Given a valid encoded string, return its fully decoded form. The encoding rule is: `k[substring]` means the substring inside the brackets should be repeated exactly `k` times. Encodings may be nested. Examples: - Input: `3[a]2[bc]` → Output: `aaabcbc` - Input: `3[a2[c]]` → Output: `accaccacc` - Input: `2[abc]3[cd]ef` → Output: `abcabccdcdcdef` Assume: - The input string is valid. - Repeat counts are positive integers. - The decoded output length fits in memory. Implement a function that returns the decoded string. ### Task 2: Find the Shortest Grid Path With Refueling Stations You are given an `m x n` grid. Each cell is one of the following: - `S`: starting position - `T`: target position - `.`: empty cell - `#`: blocked cell that cannot be entered - `G`: gas station You are also given an integer `fuelCapacity`. Moving one step up, down, left, or right costs 1 unit of fuel. You start at `S` with a full tank of `fuelCapacity`. When you enter a gas station cell `G`, your remaining fuel is reset to `fuelCapacity`. You may visit the same cell multiple times if your remaining fuel differs. Return the minimum number of steps needed to reach `T`. If it is impossible, return `-1`. Example: ```text grid = [ "S..#", ".G.#", "...T" ] fuelCapacity = 4 ``` A valid solution should use BFS over states such as `(row, col, remainingFuel)`, because reaching the same cell with more remaining fuel can lead to different future possibilities.

Quick Answer: This prompt evaluates proficiency in parsing and string manipulation for nested repeated-pattern decoding and in graph search and state-space modeling for fuel-constrained shortest paths.

Related Interview 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)
Bloomberg logo
Bloomberg
Dec 31, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
0
0

You are given two independent coding tasks.

Task 1: Decode a Repeated-Pattern String

Given a valid encoded string, return its fully decoded form.

The encoding rule is: k[substring] means the substring inside the brackets should be repeated exactly k times. Encodings may be nested.

Examples:

  • Input: 3[a]2[bc] → Output: aaabcbc
  • Input: 3[a2[c]] → Output: accaccacc
  • Input: 2[abc]3[cd]ef → Output: abcabccdcdcdef

Assume:

  • The input string is valid.
  • Repeat counts are positive integers.
  • The decoded output length fits in memory.

Implement a function that returns the decoded string.

Task 2: Find the Shortest Grid Path With Refueling Stations

You are given an m x n grid. Each cell is one of the following:

  • S : starting position
  • T : target position
  • . : empty cell
  • # : blocked cell that cannot be entered
  • G : gas station

You are also given an integer fuelCapacity. Moving one step up, down, left, or right costs 1 unit of fuel. You start at S with a full tank of fuelCapacity. When you enter a gas station cell G, your remaining fuel is reset to fuelCapacity. You may visit the same cell multiple times if your remaining fuel differs.

Return the minimum number of steps needed to reach T. If it is impossible, return -1.

Example:

grid = [
  "S..#",
  ".G.#",
  "...T"
]
fuelCapacity = 4

A valid solution should use BFS over states such as (row, col, remainingFuel), because reaching the same cell with more remaining fuel can lead to different future possibilities.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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