cswork / OA打开练习工作台

Susquehanna International GroupOA #2

Robot Vertical Move — Final Position

简单可在线判题

考点(AI 标注)模拟/实现

A robot starts from a point on a vertical line; U moves it up one step, and D moves it down one step. Determine its position relative to the start after all commands are processed.

输入格式

One line consisting of at least one U or D character.

输出格式

Output U if the final position is above the start, D if it is below, and an empty string if it is exactly at the start.

样例 1

输入:

UUDDUU

输出:

U

样例 2

输入:

UD

输出:

样例 3

输入:

DDU

输出:

D

样例说明

Count the net displacement from U and D.