Explore Directions Greedy
IntuitionNW , SE , NE , SW  are the direction you can think of to increase your distanceApproachexplore all the four possible dir. to have max distanceComplexit
# Intuition 
NW , SE , NE , SW  are the direction you can think of to increase your distance
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
explore all the four possible dir. to have max distance
<!-- Describe your approach to solving the problem. -->

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

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

# Code
```cpp []
class Solution {
public:
    int helper(string &str , string s , int k ) {
        int plus = 0 , minus = 0 , maxi = -1 ;
        int n =s.size() ;
        for(int i =0; i < n ; i++) {
            if( s[i] == str[0] || s[i] == str[1]  ) plus ++ ;
            else if( (s[i] == str[2] || s[i] == str[3]) && k > 0 ){ plus ++ ; k-- ; }
            else minus -- ;

            maxi = max(abs(plus + minus) , maxi) ;
        }
        return maxi ;
    }
    int maxDistance(string s, int k) {
        int K = k ;
        int n = s.size() ;
        int ans = 0 , plus = 0 , minus = 0, maxi = -1 ;

        vector<string> v = {"NWSE" , "SENW" , "NESW" , "SWNE"} ;
        for(int i = 1 ; i<=4 ; i++) {
            maxi = max(maxi , helper(v[i-1] , s , k)) ;
        }
        return maxi ;
        
    }
};
```
['Greedy', 'C++']