Transwarp interview question

1 leetcode medium problem (binary search)