HomeChallengesRepsProblemsLeaderboardTake a challenge

The wrong container

A lookup that scans a list inside a loop. Index it once instead.

Beginner15 min on the clock5 graded checks · 100 pointsC# Foundations
Graded by reading your code against the checklist below.

What you build

  • Build a lookup from the product list once, before the loop
  • Find each product by key rather than by scanning
  • Track the SKUs you have seen in a set, not a list
  • Compare SKUs without caring about case
  • Hand back a collection the caller cannot add to

Done means

Same total, same seen-SKU set, without a scan inside the loop.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. Build a keyed lookup once, outside the loop+25Choosing the right collection
  2. Look the product up instead of scanning for it+25Choosing the right collection
  3. Track what you have seen in a set+20Choosing the right collection
  4. Compare keys without caring about case+15Choosing the right collection
  5. Expose the set as read-only+15Choosing the right collection

What it teaches

The rest of C# Foundations