JPMorgan ChaseOA #19
Get Max Deletions
估计简单可在线判题
考点(AI 标注)哈希计数
Unit moves UDLR are executed on an infinite plane with no obstacles. Delete any instructions, not necessarily contiguous, while keeping the final coordinates unchanged; find the maximum number of instructions that can be deleted.
输入格式
One line with an instruction string of length 1..100000, containing only U, D, L, and R.
输出格式
Output a single integer answer.
样例 1
输入:
UDLR
输出:
4
样例 2
输入:
UUURD
输出:
2
样例 3
输入:
L
输出:
0
样例说明
The outputs of the three public examples are, in order: 4; 2; 0. These answers have been checked by independent enumeration or direct simulation.