From d757307936b0b36ea15acf71ac3773348cd681c4 Mon Sep 17 00:00:00 2001 From: SquidSpirit Date: Sat, 16 Aug 2025 23:38:29 +0800 Subject: [PATCH] feat: add initial implementation of unique paths solution --- 62_unique_path/Cargo.lock | 7 +++++++ 62_unique_path/Cargo.toml | 6 ++++++ 62_unique_path/src/main.rs | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 62_unique_path/Cargo.lock create mode 100644 62_unique_path/Cargo.toml create mode 100644 62_unique_path/src/main.rs diff --git a/62_unique_path/Cargo.lock b/62_unique_path/Cargo.lock new file mode 100644 index 0000000..11876d0 --- /dev/null +++ b/62_unique_path/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "unique_path" +version = "0.1.0" diff --git a/62_unique_path/Cargo.toml b/62_unique_path/Cargo.toml new file mode 100644 index 0000000..f315c29 --- /dev/null +++ b/62_unique_path/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "unique_path" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/62_unique_path/src/main.rs b/62_unique_path/src/main.rs new file mode 100644 index 0000000..f29d441 --- /dev/null +++ b/62_unique_path/src/main.rs @@ -0,0 +1,18 @@ +fn main() { + println!("Hello, world!"); +} + +struct Solution; + +impl Solution { + pub fn unique_paths(m: i32, n: i32) -> i32 { + let mut grid = vec![1; n as usize]; + for _ in 1..m { + for i in 1..n as usize { + grid[i] += grid[i - 1]; + } + } + + *grid.last().unwrap() + } +}