Draft
Find N smallest points in 2-D plane.
Description:
You are given a vector of points in the 2 dimensional plane (x,y) and a number "n" (n will always be smaller than the number of points in the vector).
Your task is to return the n points in the vector with the smallest L^2 norm (http://mathworld.wolfram.com/L2-Norm.html), from smallest to largest.
A point in the 2-D plane will be represented as a pair<int,int> in C++.
Example:
Input: n = 2, points = {{1,1},{3,2},{2,2},{3,4}}
norm({1,1}) = sqrt(1^2+1^2) = 1.4142135623730951
norm({3,2}) = sqrt(3^2+2^2) = 3.605551275463989
norm({2,2}) = sqrt(2^2+2^2) = 2.8284271247461903
norm({3,4}) = sqrt(1^2+1^2) = 5
Therefore the expected output is: {{1,1},{2,2}}
Algorithms
Fundamentals
Mathematics
Similar Kata:
Stats:
Created | Aug 14, 2017 |
Warriors Trained | 98 |
Total Skips | 15 |
Total Code Submissions | 122 |
Total Times Completed | 26 |
C++ Completions | 26 |
Total Stars | 0 |
% of votes with a positive feedback rating | 80% of 15 |
Total "Very Satisfied" Votes | 11 |
Total "Somewhat Satisfied" Votes | 2 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 15 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |