Varian Medical Systems interview question

Binary Search coding exercise and then explanation of the code.