pub fn zigzag_conversion(
s: String,
n_rows: i32,
alg: Option<Algorithm>,
) -> String
Expand description
Get a ZigZag matrix using given string and column-first algorithm.
Two solutions available, use second argument to decide which to use.
§Arguments
s
- original string to convert.n_rows
- total ROWs to layout the characters.
§Examples
use leetcode_rust::problems::p000_0xx::p000_006::zigzag_conversion;
let mut result_value = zigzag_conversion(String::from("PAYPALISHIRING"), 1, None);
assert_eq!(result_value, String::from("PAYPALISHIRING"));
result_value = zigzag_conversion(String::from("PAYPALISHIRING"), 2, None);
assert_eq!(result_value, String::from("PYAIHRNAPLSIIG"));
result_value = zigzag_conversion(String::from("PAYPALISHIRING"), 3, None);
assert_eq!(result_value, String::from("PAHNAPLSIIGYIR"));