This is a naive solution that uses "killer iterator" approach - this iterator kills elements by step of K, so when number of elements becomes less than K, these elements are survivors. More efficient implementation of this algorithm can exist - some math reasoning which yields direct math formula, but implementation of this will be another story.
This is a naive solution that uses "killer iterator" approach - this iterator kills elements by step of K, so when number of elements becomes less than K, these elements are survivors. More efficient implementation of this algorithm can exist - some math reasoning which yields direct math formula, but implementation of this will be another story.