This question runs in a pre-configured Salesforce environment - no personal connection required.

Given a list of Opportunity records and a cutoff date, update all open opportunities (where IsClosed is false) whose CloseDate is before the cutoff date by setting their StageName to Closed Lost. Return the count of updated records. Use bulk-safe DML - do not perform DML inside a loop.

Examples:

Input: opps = [list of opportunities], cutoffDate = 2026-01-01 Output: 5 Explanation: 5 open opportunities have a CloseDate before 2026-01-01 Input: opps = [], cutoffDate = Date.today() Output: 0 Explanation: Empty list returns 0 Input: opps = [closed opportunity], cutoffDate = 2030-12-31 Output: 0 Explanation: Already closed opportunities are not updated
Apex Code Editor

Welcome to Lightning Challenge!

How It Works

  • • Write your solution in the code editor
  • • This challenge runs without connecting your own org
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Contest Alert

🏆 #CodeEveryDay August 2026

Contest runs August 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.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In