Skip to content

Workshop · 2026–27

Competitive Programming & Algorithms

Learn to read a problem, spot its limits, and pick an approach fast enough to pass, then try it in a mini-contest.

Room
Room 300
Experience
Some coding experience

You should be comfortable with loops and arrays. Demos use Java and build on what AP Computer Science A covers.

Leads
Abhiram D., Nikhil G., Aarush S., Arav B.
Meetings
5 meetingsRound 1: Oct 27, 2026 to Jan 26, 2027. All dates

What it's about

Competitive programming means solving clearly defined problems with code, often against a clock and with strict limits on how long your program can run. Contests like USACO work this way.

Most meetings include a live demo: a slow, brute-force solution rewritten into a fast one so you can see the difference. Then you practice on LeetCode, which accepts many languages.

Day 1

  • What competitive programming is, and where to practice
  • How to read a problem: inputs, outputs, examples, and constraints
  • Time complexity, O(1) vs. O(n) vs. O(n²), explained with a shelf of books
  • Two pointers and prefix sums
  • Practice: LeetCode 167 and 1480

Planned lessons

From the Day 1 slides and the leads' five-meeting outline. Plans can change during the year.

  1. Meeting 1 · Complexity and array tricks

    • Big-O and time limits (roughly 10⁸ simple operations per second)
    • Two pointers on a sorted array
    • Prefix sums for instant range totals
    • Practice: LeetCode 167, 1480
  2. Meeting 2 · HashSets and HashMaps

    • Checking whether you've seen something in O(1)
    • Frequency counting
    • The complement trick for pair problems
    • Practice: LeetCode 217, 1
  3. Meeting 3 · Graphs on a grid

    • Nodes, edges, and 2D grids as graphs
    • Breadth-first search (BFS) for shortest paths
    • Depth-first search (DFS) and backtracking
    • Practice: LeetCode 733, 200
  4. Meeting 4 · Fast input and output in Java

    • BufferedReader and StringTokenizer instead of Scanner
    • StringBuilder for large outputs
    • Practice: USACO Bronze “Word Processor” and “Censoring”
  5. Meeting 5 · Mini-contest

    • Reading a full problem set and managing your time
    • 30 minutes, three problems, rising difficulty

Try it: two pointers

The Day 1 example. In a sorted list, start one pointer at each end and move them toward each other until the pair adds up to the target.

nums = [2, 7, 11, 15, 21] · target = 26

  1. 2
  2. 7
  3. 11
  4. 15
  5. 21

Check 1: 2 + 21 = 23. Too small. Move L right to get a bigger number.