The TransCompilator

Solved LeetCode program · 738 of 1,000

#0973 · K Closest Points to Origin

Medium Array chunk-15.md

Original English source

Keep a shared across holding 1 and -2. Keep a shared down holding 3 and 2. Keep a shared distances holding 10 and 8. Keep a shared used holding 0 and 0. Keep a shared chosen of 0. Keep a shared count of 0. Keep a shared wanted of 1.
To find. Set chosen to -1. The best is 1000000.
For every spot from 0 to the last position of across.
If item spot of used is 0 and item spot of distances is less than best, set best to item spot of distances, set chosen to spot.

Repeat while count is less than wanted.
Find. The target is chosen. Set item target of used to 1. The east is item target of across. The north is item target of down. The point is format whole number east as text. Place "," into point. The northtext is format whole number north as text. Place northtext into point. Show point. Add 1 to count.

Open in Playground Browse all 1,000 problems

Expected stdout

-2,2