||Greedy ✅|| Easy to understand || Best Method || C++ || Beginner Friendly🔥🔥
IntuitionTo maximize Manhattan distance from origin, we consider pairs of perpendicular movements (E-N, E-S, W-N, W-S). For each pair, we track how moves either
# Intuition
To maximize Manhattan distance from origin, we consider pairs of perpendicular movements (E-N, E-S, W-N, W-S). For each pair, we track how moves either contribute positively (align with target directions) or negatively (oppose target directions) and calculate the maximum possible distance achievable with k changes.

# Approach
1.For each target direction pair (E-N, E-S, W-N, W-S):

->Track running sum (base) and count of negative contributions (negCount)
For each character in string:

->If it matches target direction, contribute +1
If it opposes target direction, contribute -1 and increment negCount

->Calculate maximum possible value at current position:

>>If k ≥ negCount: can achieve prefixLen (current position + 1)
>>Otherwise: can achieve base + 2*k


>>Take minimum of this value and prefixLen




2.Return maximum value found across all calculations

# Complexity
- Time complexity:
O(n)

- Space complexity:
O(1)

# Code
```cpp []
class Solution {
public:
    int maxDistance(string s, int k) {
        int n = s.size();
        int ans = 0;
        vector<pair<char, char>> targets = {{'E', 'N'}, {'E', 'S'}, {'W', 'N'}, {'W', 'S'}};

        for (auto &tar : targets) {
            char targetH = tar.first;
            char targetV = tar.second;
            int base = 0;
            int negCount = 0;

            for (int i = 0; i < n; i++) {
                char c = s[i];
                int contrib = 0;

                if (c == 'E' || c == 'W') {
                    if (c == targetH) contrib = 1;
                    else contrib = -1;
                } else {
                    if (c == targetV) contrib = 1;
                    else contrib = -1;
                }

                base += contrib;
                if (contrib == -1) negCount++;

                int prefixLen = i + 1;
                int candidate = (k >= negCount) ? prefixLen : base + 2 * k;
                candidate = min(candidate, prefixLen);
                ans = max(ans, candidate);
            }
        }

        return ans;
    }
};
```
['Greedy', 'C++']