Skip to content

Commit 48a9bbb

Browse files
committed
docs: add problem description for 973 leetcode
1 parent 90776b3 commit 48a9bbb

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/medium/readme.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,41 @@ Put the code below in main.rs and run `cargo run`
14271427
println!("result: {}", result);
14281428
```
14291429

1430+
# 973. K Closest Points to Origin
1431+
1432+
## Description
1433+
1434+
We have a list of points on the plane. Find the K closest points to the origin (0, 0).
1435+
1436+
(Here, the distance between two points on a plane is the Euclidean distance.)
1437+
1438+
You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in.)
1439+
1440+
## Examples
1441+
1442+
```text
1443+
Input: points = [[1,3],[-2,2]], K = 1
1444+
Output: [[-2,2]]
1445+
1446+
Explanation:
1447+
The distance between (1, 3) and the origin is sqrt(10).
1448+
The distance between (-2, 2) and the origin is sqrt(8).
1449+
1450+
Since sqrt(8) < sqrt(10), (-2, 2) is closer to the origin.
1451+
We only want the closest K = 1 points from the origin, so the answer is just [[-2,2]].
1452+
```
1453+
1454+
## How to Run in main.rs
1455+
1456+
Put the code below in main.rs and run `cargo run`
1457+
1458+
```rust
1459+
let points = vec![vec![1, 3], vec![-2, 2]];
1460+
let k = 1;
1461+
let result = leetcode::medium::k_closest_points_to_origin::k_closest(points, k);
1462+
println!("result: {:?}", result);
1463+
```
1464+
14301465
# 981. Time Based Key-Value Store
14311466

14321467
## Description

src/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
- [x] [739. Daily temperatures](../src/medium/daily_temperatures.rs) -> [Problem Description](../src/medium/readme.md#739-daily-temperatures)
8888
- [x] [853. Car fleet](../src/medium/car_fleet.rs) -> [Problem Description](../src/medium/readme.md#853-car-fleet)
8989
- [x] [875. Koko eating bananas](../src/medium/koko_eating_bananas.rs) -> [Problem Description](../src/medium/readme.md#875-koko-eating-bananas)
90+
- [ ] [973. K closest points to origin](../src/medium/k_closest_points_to_origin.rs) -> [Problem Description](../src/medium/readme.md#973-k-closest-points-to-origin)
9091
- [x] [981. Time based key-value store](../src/medium/time_based_key_value_store.rs) -> [Problem Description](../src/medium/readme.md#981-time-based-key-value-store)
9192
- [x] [1448. Count good nodes in binary tree](../src/medium/count_good_nodes_in_binary_tree.rs) -> [Problem Description](../src/medium/readme.md#1448-count-good-nodes-in-binary-tree)
9293
- [Hard](../src/hard)

0 commit comments

Comments
 (0)