Max Manhattan Distance (beats 100% in time and space)
IntuitionTracking Directional Countse and w track the counts of 'E' and 'W'.
n and s_count track the counts of 'N' and 'S'.
The absolute differences (bx and by)
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Tracking Directional Counts

e and w track the counts of 'E' and 'W'.
n and s_count track the counts of 'N' and 'S'.
The absolute differences (bx and by) represent net movement in the x and y directions.
hx and hy represent the smaller count of opposing directions, which helps determine how many swaps can be used to maximize movement.
Computing the Maximum Distance (cur)
captures the net x-y movement, plus potential corrections using k swaps.
The min(k, hx + hy) part ensures we don't exceed available swaps.
The value of cur is clamped to i, ensuring it doesn't exceed the number of processed characters.
Updating res

The maximum cur found so far is stored in res.


# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(N)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(1)

# Code
```python3 []
class Solution:
    def maxDistance(self, s: str, k: int) -> int:
        from collections import Counter
        
        res = 0
        e = w = n = s_count = 0
        for i, ch in enumerate(s, 1):
            if ch == 'E': e += 1
            elif ch == 'W': w += 1
            elif ch == 'N': n += 1
            else: s_count += 1
            bx = abs(e - w)
            hx = min(e, w)
            by = abs(n - s_count)
            hy = min(n, s_count)
            cur = bx + by + 2 * min(k, hx + hy)
            if cur > i: cur = i
            if cur > res: res = cur
        return res

```
['Python3']