Company: PharmEasy_22aug
Difficulty: medium
Maximum displacement Problem Description You stand at the starting point of a one-dimensional lane. You are given a string of commands Str . The command S moves you one step ahead, and the command R moves you one step back. Before the commands are executed, you must make exactly N changes to the string. A change picks one command and replaces it with the other command: S becomes R , or R becomes S . (inferred -- the source says only "changing" a command; with just two commands, a change can only swap one for the other.) The same command may be changed several times, and every change counts towards N . After the N changes, all commands of the string are executed from left to right. Find the maximum displacement from the starting point that you can achieve. The displacement is the distance between your final position and the starting point, so ending k steps behind the start counts the same as ending k steps ahead of it. (inferred -- the source asks for the maximum displacement "from the