diff options
| author | Mistivia <i@mistivia.com> | 2025-09-06 23:17:22 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-09-06 23:17:41 +0800 |
| commit | ad95cba8220e2a7c86362caeb76e1a4333e9c2b8 (patch) | |
| tree | 30b31d94e2ceb46d4e946bfa1eb88b956508f760 /rust/src/bin/p0006.rs | |
| parent | 5dd8dcdc2ccfa89d25a3cb342a2f89c644236971 (diff) | |
refactor
Diffstat (limited to 'rust/src/bin/p0006.rs')
| -rw-r--r-- | rust/src/bin/p0006.rs | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/rust/src/bin/p0006.rs b/rust/src/bin/p0006.rs deleted file mode 100644 index 92e4b6f..0000000 --- a/rust/src/bin/p0006.rs +++ /dev/null @@ -1,40 +0,0 @@ -impl Solution { - pub fn convert(s: String, num_rows: i32) -> String { - if num_rows <= 1 { - return s; - } - let mut x = 0; - let mut y = 0; - let mut path: Vec<(i32,i32)> = vec!(); - let mut is_down = true; - for _ in 0..s.len() { - path.push((x, y)); - if is_down { - y = y + 1; - if y == num_rows - 1 { - is_down = false; - } - } else { - y = y - 1; - x = x + 1; - if y == 0 { - is_down = true; - } - } - } - let mut lines: Vec<String> = vec!(); - for _ in 0..num_rows { - lines.push("".to_string()); - } - for i in 0..s.len() { - let (_,y) = path[i]; - lines[y as usize].push(s.as_bytes()[i] as char); - } - lines.join("") - } -} - -struct Solution {} -fn main() { - println!("{}", Solution::convert("PAYPALISHIRING".to_string(), 3)); -}
\ No newline at end of file |
