Count the number of weekdays (Monday through Friday) in a given month and year. A weekday is any day from Monday to Friday, excluding weekends (Saturday and Sunday).

Examples:

Input: year = 2025, month = 1 Output: 23 Explanation: January 2025 has 23 weekdays Input: year = 2025, month = 2 Output: 20 Explanation: February 2025 has 20 weekdays Input: year = 2024, month = 12 Output: 22 Explanation: December 2024 has 22 weekdays
Apex Code Editor

Welcome to Lightning Challenge!

Create an Account

Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.

Create account

How It Works

  • • Write your solution in the code editor
  • • Connect your Salesforce org to test
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Note

You can test your code by connecting to Salesforce, but to save your progress and earn points, you'll need to create an account. Your solutions and achievements will be tracked automatically once you're logged in.