You are viewing a single comment's thread. Return to all comments →
Or you can one line it with LINQ
Console.Write(string.Join(" ", a.Skip(k).Concat(a.Take(k)).ToArray()));
While it is definitely elegant looking with a single line of code, how many times will this iterate over the array when performing 'skip', 'take' and 'concating' them? In other words, what's the complexity of this algorithm?
Any resources that explain how this works? I definitely see that it works, but say k is 5 in the first example and the array is 12345, it looks like we're skipping the whole array, then concatenating that whole array back to it with Take(5). What am I missing? Thank you for your time.