What is the best solution for the question, find the number of "010" or "101" in a binary string.
Example" -> "00101", here the number 010 would be 3 and 101 would be 1. So in total ans is 4.
I was able to solve it in O(N2), But i think this can be solved in O(N). Does anyone
know a better solution??