Sliding Window ||Greedy 
Intuitionjust follow the noraml process , get manhaton for each index
then check for which positions it is betraying the previous distance (if you observe the m
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
just follow the noraml process , get manhaton for each index
then check for which positions it is betraying the previous distance (if you observe the manhaton will ony inc by 1 or dec 1 at each succesive distance )
Make a window to cancel those betrays (at most k)


# Approach
<!-- Describe your approach to solving the problem. -->
1) make manhanton arrrayy v
2) make betreyal array v2
3) make window for each element having at most k betrayls and get the max (we need a to handle implementation a little carefully  )

# 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(n)


# Code
```cpp []
class Solution {
public:

    int maxDistance(string s, int k) {
        int n=s.size();
        vector<int>v(n);
        for(int i=0,x=0,y=0;i<n;i++){
            if(s[i]=='N'){
                y++;   
            }   if(s[i]=='S'){
                y--;  
            }   if(s[i]=='E'){x++;
                
            }   if(s[i]=='W'){ x--;    
                
            }
            v[i]=abs(x)+abs(y);
        }
        vector<int>v2(n+1,1);
        for(int i=1;i<n;i++)v2[i]=v[i]-v[i-1];
        int i=0,j=0;
        int ans=0;
        while(i<n){
            while(k>=0&&j<=n){
                if(v2[j]==-1)k--;
                j++;
            }
            if(v2[i]==-1)
                ans=max(ans,j-i-2+v[i-1]+1);
            else 
            ans=max(ans,j-i-2+v[i]);
            if(v2[i]==-1)k++;
            i++;
        }
       return ans;
        
    }
};
```
['Greedy', 'Sliding Window', 'C++']