Algorithms
Find a duplicate in an array | Pigeonhole principle (typescript)
My solution to a “Daily Coding Problem” that I received in my mail today. You are given an array of length n + 1 whose elements belong to the set {1, 2, …, n}. By the pigeonhole principle, there must be a duplicate. Find it in linear time and space. Daily coding problem Read more…