Question d’entretien chez TikTok

LC easy solved with binary search