Ad
  • Custom User Avatar

    You're welcome! We're all in the same boat here - studying and practising.
    Your solution is the most upvoted, so I chose it to leave a comment to give other people clue that there might be different, arguably more optimal approach.

  • Custom User Avatar

    Yeah You're Idea suits it better,(the idea of using a ring is just out of the box). I mean mine are you kidding it is just trash code, not fit for production - I'm learning GO .. and it's a good thing to learn from developers like you,

    Thanks for the better answer I really appreciate that!

  • Custom User Avatar

    Aren't there too many memory allocations? We remove elements from the middle of the original items all the time.
    IMO circular list fits better.

  • Custom User Avatar

    My solution is the same. But I use static result slice size. It gives me almost 2 times better performance. Example benchmarking for my and your code:
    BenchmarkJosephusDmitryermichev-4 5081414 207 ns/op
    BenchmarkJosephusRobinDeNeef-4 3175298 376 ns/op