Write a method that finds the longest sequence of consecutive zeros in a list of integers and returns the length of that sequence. A sequence is broken by any non-zero number.
Examples:
Input: numbers = [1, 0, 0, 0, 2, 0, 0, 4]
Output: 3
Explanation: The longest sequence has 3 zeros between 1 and 2
Input: numbers = [0, 0, 5, 0, 0, 0]
Output: 3
Explanation: There are two sequences of zeros - length 2 at start and length 3 at end. 3 is longest.
Apex Code Editor
Welcome to Lightning Challenge!
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
Contest Alert
🏆 #CodeEveryDay October 2026 (Oct 4–15)Sponsored by FLXBL
Contest runs October 4 - 15. Complete challenges to climb the leaderboard!
Prizes 1 & 2: Salesforce certification exam voucher — won by random drawing, where every point is a ticket. see all prizes
Only the 12 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.