Apple ICT5 - Phone Screen
Summary
I recently had a phone screen for an ICT5 role at Apple, where I was presented with a specific board game problem related to capturing stones.
Full Experience
During my phone screen with Apple for an ICT5 position, the interviewer posed an intriguing problem involving a game board. The task was to simulate placing a new black stone at a given (row, col) on a board and then determine the total count of white stones that would be captured as a result of this move. The board itself was represented by a 2D array, with 'e' for empty, 'b' for black, and 'w' for white. I had to devise an algorithm to identify and count all white stones that would become surrounded and captured by the newly placed black stone, alongside any existing black stones.
Interview Questions (1)
Given a game board and a position (row, col) where a black stone is about to be placed, return the number of white stones captured by black. The board is represented as a 2D array of characters.
Example:board = [ ['e', 'e', 'e', 'e', 'b', 'b', 'b'],
['e', 'e', 'e', 'e', 'b', 'w', 'b'],
['e', 'e', 'e', 'e', 'b', 'e', 'b'],
['e', 'e', 'e', 'e', 'e', 'e', 'e']]
If row = 2, col = 5 (where a black stone will be placed next), return the number of white stones captured by black.