Also, your *binary_search_right()* is incorrect, it fails when *left = 
10**9 - 1* and *func(10**9)* is *HIT*
In this case, it returns *10**9 - 1* instead of *10**9*

Wrong implementation:
*def binary_search_right(self, left, func):*
*    right = 10**9*
*    while left < right:*
*        m = (left + right) // 2*
*        f = func(m)*
*        if f == 'HIT':*
*            left = m + 1*
*        elif f == 'MISS':*
*            right = m*
*        else:*
*            return None*
*    return right - 1*


Correct implementation:
*def binary_search_right(self, left, func):*
*    right = 10**9*
*    while left < right:*
*        m = (left + right + 1) // 2*
*        f = func(m)*
*        if f == 'HIT':*
*            left = m*
*        elif f == 'MISS':*
*            right = m - 1*
*        else:*
*            return None*
*    return right*

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/bd58d574-1c92-4606-a56a-ad4c9976a09b%40googlegroups.com.

Reply via email to