Skip to content

Commit 1245116

Browse files
committed
docs: add algorithm description
1 parent 0dc3f23 commit 1245116

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/hard/trapping_rain_water.rs

+12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ pub fn trap(height: Vec<i32>) -> i32 {
2828
return max_capacity;
2929
}
3030

31+
/*
32+
Algorithm - Two Pointers
33+
34+
Time O(N)
35+
Space O(1)
36+
37+
Explanation:
38+
- The idea is to use two pointers to track the left and right side of the container
39+
- The capacity of the container is determined by the shorter side
40+
41+
*/
42+
3143
#[cfg(test)]
3244
mod tests {
3345
use super::*;

0 commit comments

Comments
 (0)