Function leetcode_rust::problems_cn::p000_0xx::p000_006::zigzag_conversion
source · Expand description
Z 字形变换
可以通过第三个参数选择要使用的算法
Arguments
s
- 等待变换的字符串n_rows
- 变换后的行数
use leetcode_rust::problems_cn::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"));