Easy Explanation Anyone can understand Yes anyone..
IntuitionAfter processeing each charcter there are 2 thing that can happen either the distance will increase or it will decrease.if it is increasing then we are
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
After processeing each charcter there are 2 thing that can happen either the distance will increase or it will decrease.if it is increasing then we are alright if it is decreasing we will increasing the distane by usuing one K value, if k=0 then let it decrease..

# Approach
<!-- Describe your approach to solving the problem. -->
for each step calculate horizontal and verical distacne from (0,0).and then calculate Manhattern Distance from origin.

            hor+=(ch=='N')?1:(ch=='S')?-1:0;
            ver+=(ch=='E')?1:(ch=='W')?-1:0;
            int curr=Math.abs(hor)+Math.abs(ver);
compare the current dustance(curr) with the previous value 
if the currnt value is higher than prev then just increase the count by 1 and if it is less then the prev then depending availablity of K you can either increase or decrease the count.

# 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 hor=0;
        int ver=0;
        int prev=0;
       
        int count=0;
        int res=0;
        for(char ch:s.toCharArray()){
            hor+=(ch=='N')?1:(ch=='S')?-1:0;
            ver+=(ch=='E')?1:(ch=='W')?-1:0;
             int curr=Math.abs(hor)+Math.abs(ver);
             if(prev<next) {
                count++;
             }
             else if(k>0){
                count++;
                k--;
             }
             else{
                count--;
             }
             prev=curr;
             res=Math.max(res,count);
            
        }
        return res;
        
    }
}
```
['String', 'Memoization', 'Counting', 'Java']