PracHub
QuestionsPremiumLearningGuidesInterview PrepCoaches
|Home/Coding & Algorithms/Bloomberg

Solve word path in grid and trapped water

Last updated: Mar 29, 2026

Quick Overview

This pair of problems evaluates algorithmic problem-solving skills in arrays and grids, covering concepts like graph traversal/backtracking for 2D word path search and array processing techniques for computing trapped water, and tests understanding of data structures, traversal strategies, and complexity analysis.

  • easy
  • Bloomberg
  • Coding & Algorithms
  • Software Engineer

Solve word path in grid and trapped water

Company: Bloomberg

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

You are given two independent programming tasks. --- ### Problem 1: Check if a word exists in a 2D character grid You are given a 2D grid `board` of characters with `m` rows and `n` columns, and a string `word`. You need to determine if `word` can be formed by sequentially adjacent cells in the grid. Adjacent cells are horizontally or vertically neighboring (no diagonals). The same cell **cannot** be used more than once in forming the word. Return `true` if the word exists in the grid, and `false` otherwise. **Example:** Input: - `board = [ ['A','B','C','E'], ['S','F','C','S'], ['A','D','E','E'] ]` - `word = "ABCCED"` Output: `true` Explanation: The word can be formed by the path `A -> B -> C -> C -> E -> D` using adjacent cells without reusing any cell. **Constraints (you may assume any reasonable values if not given):** - `1 <= m, n <= 10^2` - `1 <= len(word) <= m * n` - `board[i][j]` is an uppercase or lowercase English letter. Describe an algorithm to solve this problem and analyze its time and space complexity. --- ### Problem 2: Compute total water trapped between bars You are given an array `height` where each element `height[i]` represents the height of a vertical bar of width 1 at position `i`. After raining, water may be trapped between the bars. Compute how many units of water are trapped between the bars. Return the total amount of trapped water as an integer. **Example 1:** Input: - `height = [0,1,0,2,1,0,1,3,2,1,2,1]` Output: `6` Explanation: 6 units of water are trapped in the valleys formed by the bars. **Example 2:** Input: - `height = [4,2,0,3,2,5]` Output: `9` **Constraints (you may assume any reasonable values if not given):** - `1 <= height.length <= 2 * 10^5` - `0 <= height[i] <= 10^4` Design an efficient algorithm (both time and space) to compute the trapped water and analyze its complexity. An in-place or two-pointer solution is preferred in an interview setting.

Quick Answer: This pair of problems evaluates algorithmic problem-solving skills in arrays and grids, covering concepts like graph traversal/backtracking for 2D word path search and array processing techniques for computing trapped water, and tests understanding of data structures, traversal strategies, and complexity analysis.

Related Interview Questions

  • Solve meeting and tree problems - Bloomberg (easy)
  • Check connectivity between two subway stations - Bloomberg (easy)
  • Minimize travel cost with two cities - Bloomberg (easy)
  • Find tree root and bucket numbers - Bloomberg (hard)
  • Design a data structure for dynamic top‑K frequency - Bloomberg (hard)
Bloomberg logo
Bloomberg
Nov 25, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
5
0

You are given two independent programming tasks.

Problem 1: Check if a word exists in a 2D character grid

You are given a 2D grid board of characters with m rows and n columns, and a string word.

You need to determine if word can be formed by sequentially adjacent cells in the grid. Adjacent cells are horizontally or vertically neighboring (no diagonals). The same cell cannot be used more than once in forming the word.

Return true if the word exists in the grid, and false otherwise.

Example:

Input:

  • board = [ ['A','B','C','E'], ['S','F','C','S'], ['A','D','E','E'] ]
  • word = "ABCCED"

Output: true

Explanation: The word can be formed by the path A -> B -> C -> C -> E -> D using adjacent cells without reusing any cell.

Constraints (you may assume any reasonable values if not given):

  • 1 <= m, n <= 10^2
  • 1 <= len(word) <= m * n
  • board[i][j] is an uppercase or lowercase English letter.

Describe an algorithm to solve this problem and analyze its time and space complexity.

Problem 2: Compute total water trapped between bars

You are given an array height where each element height[i] represents the height of a vertical bar of width 1 at position i. After raining, water may be trapped between the bars.

Compute how many units of water are trapped between the bars.

Return the total amount of trapped water as an integer.

Example 1:

Input:

  • height = [0,1,0,2,1,0,1,3,2,1,2,1]

Output: 6

Explanation: 6 units of water are trapped in the valleys formed by the bars.

Example 2:

Input:

  • height = [4,2,0,3,2,5]

Output: 9

Constraints (you may assume any reasonable values if not given):

  • 1 <= height.length <= 2 * 10^5
  • 0 <= height[i] <= 10^4

Design an efficient algorithm (both time and space) to compute the trapped water and analyze its complexity. An in-place or two-pointer solution is preferred in an interview setting.

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.