Solved Should approved be a set instead of a list? FRFreyaLOP 21 Sep, 08:07 in on a list checks every item. Wouldn't a set be faster?
SASamPrice21 Sep, 09:30 Solutionreplies: 1Yes, for large collections a set is much faster (constant time lookup). For a handful of IDs it doesn't matter. The challenge uses a list to keep it simple, but your instinct is right for real code.
TOTomBecker21 Sep, 20:33Stage 2 cleaning with strip + upper is the important part. Hand-typed IDs are always messy.
Comments 4
Join the discussion CommentAlready have an account? Log in
Yes, for large collections a set is much faster (constant time lookup). For a handful of IDs it doesn't matter. The challenge uses a list to keep it simple, but your instinct is right for real code.
Good to know I'm thinking in the right direction.
Remember the nested loops article — sets turned minutes into seconds there.
Stage 2 cleaning with strip + upper is the important part. Hand-typed IDs are always messy.