Skip to content

Commit c21ecc7

Browse files
committed
feat: add docs for 42 problem
1 parent a58aa3d commit c21ecc7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/hard/readme.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
# 42. Trapping Rain Water
2+
3+
## Description
4+
5+
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.
6+
7+
## Examples
8+
9+
Example 1:
10+
11+
```
12+
Input: height = [0,1,0,2,1,0,1,3,2,1,2,1]
13+
Output: 6
14+
Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped.
15+
```
16+
17+
Example 2:
18+
19+
```
20+
Input: height = [4,2,0,3,2,5]
21+
Output: 9
22+
```
23+
24+
## How to Run in main.rs
25+
26+
Put the code below in main.rs and run `cargo run`
27+
28+
```rust
29+
let height = vec![0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1];
30+
let result = hard::trapping_rain_water::trap(height);
31+
println!("result: {:?}", result);
32+
```
33+
134
# 84. Largest Rectangle in Histogram
235

336
## Description

0 commit comments

Comments
 (0)