2
static class Distance {7
public Distance(int i, int j, double dist) {14
public int[][] kClosest(int[][] points, int k) {15
PriorityQueue<Distance> pq = new PriorityQueue<>((x, y) -> Double.compare(x.dist, y.dist));16
for (int[] point : points) {17
double dist = calcDistance(point[0], point[1]);18
pq.offer(new Distance(point[0], point[1], dist));21
ArrayList<int[]> l = new ArrayList<>();23
Distance d = pq.poll();24
l.add(new int[] {d.i, d.j});27
int[][] res = l.toArray(new int[l.size()][]);31
private double calcDistance(int i, int j) {32
double dist = Math.sqrt(Math.pow(i, 2) + Math.pow(j, 2));