In a long hallway some soldiers are walking from left to right and some from right to left all at the same speed.
Every time while walking they cross through another soldier they salute and move ahead.
Given a string A of length N showing the soldiers' direction they are walking. '<' denotes a soldier is walking from right to left, and '>' denotes a soldier is walking from left to right. Return the number of Salutes done.
A = '>>><<<'
A = '<>'
Soldier 1 will salute with 4, 5, 6. Same goes for soldier 2 and 3. Hence, the total number of salutes is 9.
There will be no salutes as no two soldiers will cross each other.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.