Interview Query

Median O(1)

Start Timer

0:00:00

Upvote
6
Downvote
Save question
Mark as completed
View comments (10)
Next question

You’re given a list of sorted integers in which more than 50% of the list is comprised of the same repeating integer.

Write a function to return the median value of the list in O(1)O(1) computational time and space.

Note: the lists are all non-empty

Example:

Input:

li = [1,2,2]

Output:

median(li) -> 2
.
.
.
.
.


Comments

Loading comments