Learn
Practice
Newsletter
Resources
Resume
New
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
K Closest Points to Origin
Bookmark
Input
Small (k=2)
Medium (k=3)
Two points (k=1)
Equal distance
Custom
points
=
[[1,3],[-2,2],[5,8],[0,1],[-3,-1]]
,
k
=
2
[1,3]
[-2,2]
[5,8]
[0,1]
[-3,-1]
algo
master
.
io
Step:
Start: Initialize algorithm
Variable
Value
points
Matrix(5x2) [[1,3]...]
k
2
heap
-
i
-
Variable
Value
x
-
y
-
distance
-
max_distance
-
0 / 15
Input
Small (k=2)
Medium (k=3)
Two points (k=1)
Equal distance
Custom
points
=
[[1,3],[-2,2],[5,8],[0,1],[-3,-1]]
,
k
=
2
0 / 15
[1,3]
[-2,2]
[5,8]
[0,1]
[-3,-1]
algo
master
.
io
Step:
Start: Initialize algorithm
Visualization
Variables