判断是否为闰年
class Solution { public int numberOfDays(int Y, int M) { int arr[] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; if(is_Leap(Y)&&M==2) return 29; else return arr[M]; } public static boolean is_Leap(int i) { if(i%4==0&&i%100!=0|| i%400==0) { return true; } return false; } }