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 accountHow 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
Contest Alert
🏆 #CodeEveryDay May 2026
Contest runs May 1 - 31. Complete challenges to climb the leaderboard!
Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.