FastPrepTransform L/R Pieces on a Circular Board
Problems/Transform L/R Pieces on a Circular Board

Transform L/R Pieces on a Circular Board

Google logoGoogle● HardNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives the linear L/R movement rules, moves of any distance and order, a rule that pieces cannot cross, the goal of deciding whether start can reach target, and a follow-up with a circular board. The original author confirms that leaving one side means coming back in from the other, and says they got a hint from the interviewer for the circular case. We chose the character encoding, a shared function flag, finite limits, and a way to unroll the cyclic order. Our version is about 90% the same as the reported question.

start and target describe boards of equal length. Each cell is 'L', 'R', or '.'.

  • An 'L' piece moves only left.
  • An 'R' piece moves only right.
  • A piece may move any positive distance through empty cells, but it may not pass through or land on another piece.
  • Pieces may move in any order.

If circular is false, pieces cannot leave the board. If circular is true, the board wraps: moving left from index 0 continues at index n - 1, and moving right from index n - 1 continues at index 0.

Return whether start can be transformed into target.

Function

canTransformLRPieces(start: String, target: String, circular: boolean) → boolean

Examples

Example 1

start = ".L..R..R."target = "L......RR"circular = falsereturn = true

The nonempty piece order is unchanged. L moves from 1 to 0, while the two R pieces move from 4 and 7 to 7 and 8.

Example 2

start = "L.."target = "..L"circular = truereturn = true

The L piece leaves index 0 through the left boundary and re-enters at index 2.

Example 3

start = "RL.."target = "LR.."circular = truereturn = false

Each piece is immediately blocked in its allowed direction. Reaching the target would require the two pieces to cross.

Constraints

  • 1 <= start.length == target.length <= 3000.
  • Both strings contain only 'L', 'R', and '.'.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Palindrome Match PercentageApple · ONSITE INTERVIEW
  • Add Signed Character ArraysByteDance · PHONE SCREEN
  • Next Palindrome NumberBenchling · PHONE SCREEN
  • Parse, Normalize, and Combine PolynomialsSquarepoint Capital · PHONE SCREEN
  • Alphabetically Maximum SubstringOracle · PHONE SCREEN
  • Integer to English Words: Up to 20 DigitsPeopleStrong · ONSITE INTERVIEW
  • Signed Digit Partitions Reaching a TargetMeta · PHONE SCREEN
  • Longest Properly Closed Bracket RunAdobe · PHONE SCREEN
  • Indexed Proximity SearchStripe · PHONE SCREEN
  • Run-Length Encoding and DecodingAirbnb · PHONE SCREEN
See Google hiring insights
Saved
class Solution {
    public boolean canTransformLRPieces(String start, String target, boolean circular) {
        // write your code here
    }
}
Checking account…