2 ms·
This finds the mode (most common element), not the median. Wouldn't you also need to keep track of all element counts with your approach? You can't keep the co
by gcr 2y ago
This finds the mode (most common element), not the median.
Wouldn't you also need to keep track of all element counts with your approach? You can't keep the count of only the second-most-common element because you don't know what that is yet.
- zelphirkalt 2y agoYes, you are right. I mixed up mode and median. And yes, one would need to keep track of at least a key for each element (not a huge element, if they are somehow huge). But that would be about space complexity.
- gcr 2y agopardon! it's fun to think about though!