LeetCode 1118. Number of Days in a Month

Problem Statement


impl Solution {
fn is_leap_year(y: i32) -> bool {
return (y % 4 == 0 && y % 100 != 0) || (y % 400 == 0);
}

pub fn number_of_days(y: i32, m: i32) -> i32 {
let feb = match Self::is_leap_year(y) {
true => 29,
false => 28
};
let ans = vec![31,feb,31,30,31,30,31,31,30,31,30,31];
return ans[m as usize - 1];
}
}