Skip to content

Commit 4b94eab

Browse files
committed
Added Zigzag Conversion Structure
1 parent 44a1865 commit 4b94eab

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub mod add_two_numbers; // 2
1919
pub mod length_of_longest_substring; // 3 ✓
2020
pub mod median_of_two_sorted_arrays; // 4
2121
pub mod longest_palindromic_substring; // 5
22-
22+
pub mod zigzag_conversion; // 6
2323
pub mod reverse_integer; // 7
2424
pub mod string_to_integer; // 8
2525
pub mod palindrome_number; // 9

src/zigzag_conversion.rs

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/// The string "PAYPALISHIRING" is written in zigzag pattern on a given number
2+
/// of rows like this:
3+
///
4+
/// P A H N
5+
/// A P L S I I G
6+
/// Y I R
7+
///
8+
/// And then read line by line: "PAHNAPLSIIGYIR"
9+
///
10+
/// Write the code that will take a string and make this conversion given a
11+
/// number of rows:
12+
struct Solution;
13+
14+
impl Solution {
15+
16+
// TODO: Implement
17+
pub fn convert(_s: String, _num_rows: i32) -> String {
18+
"".to_string()
19+
}
20+
21+
}
22+
23+
#[cfg(test)]
24+
mod tests {
25+
use super::Solution;
26+
27+
#[ignore]
28+
#[test]
29+
fn example_1() {
30+
let s = "PAYPALISHIRING".to_string();
31+
let num_rows = 3;
32+
let result = Solution::convert(s, num_rows);
33+
assert_eq!(result, "PAHNAPLSIIGYIR");
34+
}
35+
36+
#[ignore]
37+
#[test]
38+
fn example_2() {
39+
let s = "PAYPALISHIRING".to_string();
40+
let num_rows = 4;
41+
let result = Solution::convert(s, num_rows);
42+
assert_eq!(result, "PINALSIGYAHRPI");
43+
}
44+
45+
#[ignore]
46+
#[test]
47+
fn example_3() {
48+
let s = "A".to_string();
49+
let num_rows = 1;
50+
let result = Solution::convert(s, num_rows);
51+
assert_eq!(result, "A");
52+
}
53+
54+
}

0 commit comments

Comments
 (0)