Implemented getWordSpans using binary search.