Closed fave77 closed 5 years ago
A suggestion: We can implement a general findRank() function first and then use it for this function.
@sateslayer what would that function do?
Find the number present in the array at any valid rank in O(n) time.
Rank(x) = 1 + {number of numbers >= x)
example: arr = [1, 5, 2, 7, 2, 8] findElementAtRank(3) = 5; findElementAtRank(arr.length) = 1 findElementAtRank(4) = none //Error findElementAtRank(5) = 2 //Both the two's hold equal rank/priority
Therefore, findMedian(arr) = findElementAtRank(arr.length/2); //Separate handling for odd number of elements as per requirement.
I Wanna take up this issue @pbiswas101 !
@Manvityagi please don't comment under every issue, I've assigned you #109 as per your latest comment. First, decide which one you would like to work on and then claim that issue.
Sorry, I would like to first work on this as I have already almost completed it!
@Manvityagi why did you started working before being assigned? I'm sorry but first complete the other one and then if no one else claims this issue by then, I'll assign this one to you.
okay!!
@Manvityagi you're assigned!
Do the checklist before filing the issue:
NOTE: Provide a clear and concise description of the feature that needs to be added! Or if its a bug, then provide the necessary steps to reproduce it along with screenshots.