Link to the video : Ternary String
I have added this as a practice problem to my binary search course , so if you want to learn binary search and want to know how binary search can be used to solve beautiful problems like these do checkout my course on that , link is given below
Course Link : null - YouTube