FastPrepClassify Final Robot Displacement
Problems/Classify Final Robot Displacement

Classify Final Robot Displacement

ZipRecruiter logoZipRecruiter● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter OA report describes the U and D movement rules and a three-way result of U, empty string, or D based on the final displacement. The employment label is not known, and the report leaves out limits, a function signature, examples, and image data. So our version uses the full-time default and supplies those details.

A robot starts at vertical position 0 and follows the characters in commands from left to right.

  • U moves the robot one step up.
  • D moves the robot one step down.

Return \"U\" if the final position is above the start, an empty string if it is at the start, or \"D\" if it is below the start.

Function

classifyVerticalDisplacement(commands: String) → String

Examples

Example 1

commands = "UUDDUDU"return = "U"

Four up moves and three down moves leave the robot one step above the start.

Example 2

commands = "UDDU"return = ""

Two up moves and two down moves cancel, so the robot returns to its starting position.

Constraints

  • 1 <= commands.length <= 100000
  • commands contains only U and D.

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

Similar questions at other companies

  • Branch with the Most FilesCapital One · OACapital One interview questions
  • Robot Stops Left or Right (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
  • REST API: Highest International StudentsRippling · OARippling interview questions
  • Rearrange String by Alternating EndsHudson River Trading · OAHudson River Trading interview questions
  • Filter Isolated Interior Signal BitsSEDEMAC · OA
  • Scale Ingredient QuantitiesUpstart · OAUpstart interview questions
  • Telephone Keypad String EncodingEpic · OAEpic interview questions
  • Count Invalid Log GroupsIBM · OAIBM interview questions
  • Count Case-Insensitive TripletsTikTok · OATikTok interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public String classifyVerticalDisplacement(String commands) {
        // Write your code here.
    }

}
Checking account…