binary-search algorithm practice: Finding the last index of an element in a sorted array with duplicates