Bloomberg Interview Question: Binary Strings with Wildcards (Examples Version)

13 Views
No Comments
Binary Strings with Wildcards

Input: "01?0"  -> 0100, 0110
Input: "01??" -> 0100, 0110, 0111, 0101

This is the same wildcard-binary problem in a shorter form: given a binary string containing ?, generate all possible binary strings by replacing each ? with 0 or 1. The examples show how a single ? doubles the outputs, and multiple wildcards lead to 2^k combinations where k is the number of ? characters.


Bloomberg Interview Question: Desert Ride with Rocks (Blocked Cells)

// const desert = [
//   ['.', '.', '.', '.', '.', '.', '.', 'o'],
//   ['.', 'r', 'r', 'r', 'r', 'r', 'r', 'r'],
//   ['.', '.', '.', '.', '.', '.', '.', '.'],
//   ['.', '.', 'c', '.', '.', '.', '.', '.'],
// ];
//
// .  sand
// c  car
// o  oasis
// r  rock
//
// ride(desert, 5) -> false

English Summary
This variant of the desert problem adds rocks ('r') as blocked cells. The car starts at 'c', wants to reach 'o', and can move up/down/left/right through sand '.' only. Each move costs 1 unit of gas; rocks cannot be entered. You must determine whether the car can reach the oasis with at most gas steps (here, 5), which requires a shortest-path search like BFS that treats rock cells as walls.

END
 0