3 ms·
What if we rephrased it as having the lists sorted by additional field "category", and you are supposed to reset the counter in a new category?
by js8 6y ago
What if we rephrased it as having the lists sorted by additional field "category", and you are supposed to reset the counter in a new category?
- josevalim 6y agoCorrect. In the real-life example this came from, a separate parameter would control how to reset the lesson counter but it was moved into a boolean property to keep the problem focused. Your "category" idea would be a nice addition to the problem though. The logic of when to reset would still be fairly simple and folks would have to explore how to represent the initial category value before traversal starts. I assume most would solve it with nil and maybe/option types.