rewrite leetcode search for a rangeg