//The answer is simple the only tricky thing is the ans+=right-left+1; because of which I got stuck //Here's an amazing explanation for that | taken form https ...