modify binary search to find the next bigger item than the key
问题 I want to modify the famous binary search algorithm to return the index of the next bigger item instead of the key being searched. So we have 4 cases: the key is smaller than all items, return 0. the key is bigger than all items, return items.length. the key is found at index x, return x+1. the key isn't found, return the index of the next bigger one. e.g: data = { 1, 3, 5, 7, 9, 11 }; search for 0 returns 0. search for 11 or 12 returns 6. search for 5 or 6 returns 3. while (low <= high) {