FastPrepTransform L/R Pieces With Barriers
Problems/Transform L/R Pieces With Barriers

Transform L/R Pieces With Barriers

Google logoGoogle● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names a well-known L/R piece transformation problem and adds an immovable '|' piece that no other piece may cross. We chose how dots are encoded, the examples, the function signature, and the input limits. This barrier variant stays separate from the related circular-board follow-up, because the interviewer's extensions set different movement rules. Our version is about 93% the same as the reported question.

start and target are boards of equal length containing four characters:

  • 'L' is a piece that moves only left.
  • 'R' is a piece that moves only right.
  • '.' is an empty cell.
  • '|' is an immovable barrier.

A piece may move through empty cells, but it may not pass through another piece or a barrier. Barriers never move. Pieces may move in any order.

Return whether start can be transformed into target.

Function

canTransformWithBarriers(start: String, target: String) → boolean

Examples

Example 1

start = ".L.|R.."target = "L..|..R"return = true

Within the left segment, L moves from index 1 to 0. Within the right segment, R moves from index 4 to 6. Neither piece crosses the barrier at index 3.

Example 2

start = "R..|..L"target = "..R|L.."return = true

R moves right inside the first segment and L moves left inside the second segment.

Example 3

start = "R.|..."target = "..|R.."return = false

The R piece would have to cross the fixed barrier at index 2.

Constraints

  • 1 <= start.length == target.length <= 100000.
  • 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

  • Longest Palindromic SubstringSiemens · PHONE SCREEN
  • Reverse Words in a StringAgoda · PHONE SCREENAgoda interview questions
  • Longest Palindromic SubstringIBM · PHONE SCREENIBM interview questions
  • Shortest Way to Form a Target StringPinterest · PHONE SCREENPinterest interview questions
  • Validate a Palindrome After Limited DeletionsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
  • Snake-Case Iterator to Camel CaseNavan · PHONE SCREENNavan interview questions
  • Reverse Word Order In PlaceMicrosoft · PHONE SCREENMicrosoft interview questions
  • String CompressionBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Compare Version NumbersInMobi · PHONE SCREENInMobi interview questions

Interview reports that mention this question

  • Google Early Career R1 L/R Pieces and BQ: 1 Experience

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public boolean canTransformWithBarriers(String start, String target) {
        // write your code here
    }
}
Checking account…