Skip to content

Latest commit

 

History

History
 
 

day-7-spearman-rank-correlation-coefficient

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Day 7: Spearman's Rank Correlation Coefficient

https://www.hackerrank.com/challenges/s10-spearman-rank-correlation-coefficient

Problem

In this challenge, we practice calculating Spearman's rank correlation coefficient.

Task

Given two n-element data sets, X and Y, calculate the value of the Spearman's rank correlation coefficient.

Input Format

The first line contains an integer, n, denoting the size of data sets X and Y.
The second line contains n space-separated real numbers (scaled to at most one decimal place), defining data set X.
The third line contains n space-separated real numbers (scaled to at most one decimal place), defining data set Y.

Output Format

Print the value of the Spearman's rank correlation coefficient, rounded to a scale of 3 decimal places.

Sample Input

10
10 9.8 8 7.8 7.7 1.7 6 5 1.4 2 
200 44 32 24 22 17 15 12 8 4

Sample Output

0.903

My Solution