Java Easy Explaination 
IntuitionFor maximum Manhattan distance we need to get max on x-axis and max on y-axis so if we are going in East north direction then we need to go as far as p
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
For maximum Manhattan distance we need to get max on x-axis and max on y-axis so if we are going in East north direction then we need to go as far as possible in the same direction we should avoid going in backward direction in this case best and south direction with the help of K that is given , and we need to do this in other cases es well

# Approach
<!-- Describe your approach to solving the problem. -->
1. we will try to check by going in every pair of direction with the help of for loop (hor and ver)
2. everytime we will cal the dis (wi the help of keeo tracking the x and y and k)
3. If it is similar to what we have choose in horizontal and vertical for loop then simply increase the axis if not then check if it has k  remaining and increase it otherwise decreases  it 
4.  in the end calculate the distance and store in the max

# 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
```java []

class Solution {
    public int maxDistance(String s, int k) {
   int ans = 0;
        for(char hr:new char[]{'E','W'}){
            for(char vr:new char[]{'N','S'}){
                int rm = k;
                int x = 0;
                int y = 0;
                for(char ch:s.toCharArray()){
                    if(ch=='N' || ch=='S'){
                        if(ch==vr){
                            y++;
                        }else if(rm>0){
                            y++;
                            rm--;
                        }else{
                            y--;
                        }
                    }else{
                        if(ch==hr){
                            x++;
                        }else if(rm>0){
                            x++;
                            rm--;
                        }else{
                            x--;
                        }
                    }
                    ans = Math.max(ans,Math.abs(x)+Math.abs(y));
                }
            }
        }
        return ans;
 
    }
}
```
['Java']