Accumulator patterns
- Stage
- 2
- Module
- M2.4
- Lessons
- 1
In this module
- Keep a running sum, count, minimum or maximum while looping over input.
- Track the best-so-far value with an explicit tie-breaking rule.
- Use a boolean flag to record whether something has happened yet.
Before this module
Lessons
Practice
Try these on the judges. Each link opens the problem on WMOJ or DMOJ.
- 2021 J2Silent Auction (opens on WMOJ in a new tab) WMOJ
Find the winning bid in a silent auction with several bidders.
- 2024 J3Bronze Count (opens on WMOJ in a new tab) WMOJ
Find the third-highest distinct score in a list of contest scores.
- 2017 S1Sum Game (opens on DMOJ in a new tab) DMOJ
Find the last day two teams' season totals were tied, or that they never were.
Why DMOJ: An early Senior problem, included here for extra practice.