This function performs binary search over the answer to minimise it
static int binarySearch ( String s ) { int low = 1 , high = s . length ( ) ; int ans = 0 ; while ( low <= high ) { int mid = ( high + low ) >> 1 ;