HackerRank Çözümleri – Find the Median

HackerRank içerisinde bulunan “Find the Median” sorusunun açıklaması ve çözümü. Bu soruda size verilen bir seri içerisindeki medyan değerini, yani seriyi ortadan ikiye ayıran değeri bulmanız isteniyor.

► HackerRank – Find the Median: https://www.hackerrank.com/challenges/find-the-median/problem

► Problem açıklaması:

The median of a list of numbers is essentially its middle element after sorting. The same number of elements occur after it as before. Given a list of numbers with an odd number of elements, find the median?

https://en.wikipedia.org/wiki/Median

Example

arr = [5, 3, 1, 2, 4]

The sorted array arr = [1, 2, 3, 4, 5]. The middle element and the median is 3.

Sample Input 0

7

0 1 2 4 6 5 3

Sample Output 0

3

The sorted arr = [0, 1, 2, 3, 4, 5, 6]. It’s middle element is at arr[3] = 3.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.