1. /**
    2. * @param year: a number year
    3. * @param month: a number month
    4. * @return: return the number of days of the month.
    5. */
    6. func GetTheMonthDays(year int, month int) int {
    7. // write your code here
    8. if month == 2{
    9. if isLeapYear(year) {
    10. return 29
    11. } else {
    12. return 28
    13. }
    14. } else if month == 4 || month == 6 || month == 9 || month == 11{
    15. return 30
    16. } else {
    17. return 31
    18. }
    19. }
    20. func isLeapYear(n int) bool {
    21. if n%4 == 0 && n % 100 != 0 || n % 400 == 0{
    22. return true
    23. }
    24. return false
    25. }