Editorial
Every interval containing person has . Increase the right endpoint from . Once the first position with is reached, that interval and every longer interval fail. Hence the answer is the number of positions before it. The time complexity is .