search range in a sorted array

not a good method to solve this.