DataLane

24. Pearson correlation

hardProNot started~14 minPythonImplement pearson()

Asked in screens shaped like: Two Sigma, Citadel

Return the Pearson correlation of equal-length vectors a and b, rounded to 4 decimals. Assume they are not constant.

Examples

  • Example 1

    Input: { "a": [1, 2, 3], "b": [2, 4, 6] }
    Output: 1

Constraints

  • Vectors are the same length and not constant

Python editor

Loading Python engine…

Ctrl/Cmd + Enter submits

Run your code to see stdout.

Pro problem

Hard problems unlock with Pro

Easy pads stay free. Medium and hard SQL and Python problems — editor, tests, hints, and solutions — open after you upgrade to Pro or coaching.

See plansPractice free easy problems
↑↓ navigate openesc close