If array is sorted we can generally find median in O(1) by returning the element at the middle. But what if there are duplicates?
E.g [2, 2, 3, 3, 3, 3]
If array is sorted we can generally find median in O(1) by returning the element at the middle. But what if there are duplicates?
E.g [2, 2, 3, 3, 3, 3]
Yes. Even with duplicates, the process of finding median is same. See this link - https://math.stackexchange.com/questions/1191119/how-to-find-the-median-of-three-numbers-if-one-of-them-appears-twice