#C9001. Final Drone Position
Final Drone Position
Final Drone Position
A drone is initially positioned at the origin \((0, 0)\) on an infinite lawn grid. It receives a sequence of commands as a string, where each character represents a direction:
- N - move north (increase \(y\) by 1)
- S - move south (decrease \(y\) by 1)
- E - move east (increase \(x\) by 1)
- W - move west (decrease \(x\) by 1)
Your task is to calculate the final coordinates of the drone after executing all commands in the input string. The input string length is at most 1000 characters.
For example, given the command string "NNNWW", the drone moves north three times and west twice, resulting in the position \((-2, 3)\).
inputFormat
The input is a single line string consisting solely of the characters N
, S
, E
, and W
without spaces. This string represents the sequence of moves.
outputFormat
The output should be two integers separated by a space representing the final \(x\) and \(y\) coordinates of the drone.
## sampleN
0 1