Solution to Week 8: singletons and binary search