feat: add initial implementation of unique paths solution

This commit is contained in:
SquidSpirit 2025-08-16 23:38:29 +08:00
parent c41e076cac
commit d757307936
3 changed files with 31 additions and 0 deletions

7
62_unique_path/Cargo.lock generated Normal file
View File

@ -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"

View File

@ -0,0 +1,6 @@
[package]
name = "unique_path"
version = "0.1.0"
edition = "2024"
[dependencies]

View File

@ -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()
}
}