google | mtv | phone screen | failed
Anonymous User
843

Given a sorted list of string words, then input a string, find the index of the first word with this input string as prefix

String[] s = {"aa", "aaa", "ax", "b", "c"};

find("a") = 0

find("aa") = 0

find("aaa") = 1

find("aaaa") = -1

can you do with binary search?

Comments (8)