**DRY-RUN Approach for more clearance** - 

Str = "bccbababd" AND k = 2

- Start and end = 0
- start iterating from end till N and include occurence of char in map
- If length of map is greater then k then start decreasing the character using start pointer till length of map is less then or equal to k

[![](https://i.imgur.com/uGNmVD5.jpg)](https://i.imgur.com/uGNmVD5.jpg)

**!Hope that Approach is pretty clear to you.**