Given an integer n
, add a dot (".") as the thousands separator and return it in string format.
Input: n = 987 Output: "987"
Input: n = 1234 Output: "1.234"
Input: n = 123456789 Output: "123.456.789"
Input: n = 0 Output: "0"
0 <= n < 2^31
impl Solution {
pub fn thousand_separator(n: i32) -> String {
let s = n.to_string();
let v = s.split("").filter(|&c| c != "").collect::<Vec<_>>();
let v = v.rchunks(3).rev().map(|c| c.concat()).collect::<Vec<_>>();
v.join(".")
}
}