Skip to content

Instantly share code, notes, and snippets.

@neo125874
Last active July 22, 2016 06:12
Show Gist options
  • Save neo125874/33e8b97ce1dfbd491cc7eec272377728 to your computer and use it in GitHub Desktop.
Save neo125874/33e8b97ce1dfbd491cc7eec272377728 to your computer and use it in GitHub Desktop.
Codility Lesson 2-1 Arrays
using System;
using System.Linq;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int[] solution(int[] A, int K) {
if (A == null || A.Length == 0) return A;
var B = A.ToList();
for(int i=0; i<K; i++){
var index = B.Count - 1;
var botItem = B.ElementAt(index);
B.RemoveAt(index);
B.Insert(0, botItem);
}
return B.ToArray();
// write your code in C# 6.0 with .NET 4.5 (Mono)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment