Pergunta de entrevista da empresa Jane Street

Variants on binary search

Resposta da entrevista

Sigiloso

30 de nov. de 2015

you mean "invariants"? ``` def binsearch(target, arr): lo, hi = 0, len(arr)-1 while lotarget: hi=mid-1 else: lo = mid+1 return -1 ``` invariant for binsearch is that after each while loop, the result (if exists) should be between lo and hi.