You are given a string s consisting of characters 'N', 'S', 'E', and 'W', which represents a sequence of movements on a
'N' moves one unit north to
'S' moves one unit south to
'E' moves one unit east to
'W' moves one unit west to
You are also given an integer k. You can change at most k characters in s to any of the four directional characters.
Return the maximum Manhattan distance from the origin
Note: The Manhattan distance between a point
and the origin is .
Constraints:
s.length
k s.length
s consists of only 'N', 'S', 'E', and 'W'.
You are given a string s consisting of characters 'N', 'S', 'E', and 'W', which represents a sequence of movements on a
'N' moves one unit north to
'S' moves one unit south to
'E' moves one unit east to
'W' moves one unit west to
You are also given an integer k. You can change at most k characters in s to any of the four directional characters.
Return the maximum Manhattan distance from the origin
Note: The Manhattan distance between a point
and the origin is .
Constraints:
s.length
k s.length
s consists of only 'N', 'S', 'E', and 'W'.