FastPrepApply a Reversi Move

Apply a Reversi Move

Amazon logoAmazon● MediumFULLTIMEOA

Problem statement

Given a Reversi board board, a zero-based target cell row, col, and a player player equal to B or W, apply exactly one move.

A direction captures pieces when one or more consecutive opponent pieces start next to the target and are followed, in that same direction, by one of the current player's pieces. A legal move places the player's piece and flips every captured line in all eight directions.

The problem statement continues
Pro

Examples

Example 1

board = ["....",".WB.","...."]row = 1col = 3player = "W"return = ["....",".WWW","...."]

The new white piece at column 3 brackets the black piece with the existing white piece at column 1.

FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
See Amazon hiring insights
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week