[Codility] [2–1] CyclicRotation (score 62%)

--

【Lesson 2–1】: CyclicRotation 數組進行輪轉,依次數輪轉,每次最後數字往第一位排 (score 62%)

public static int[] CyclicRotation(int[] A, int K){int i = 0;int len = A.Length;int[] B = new int[A.Length];while (i < K){B = A.Clone() as int[];B[0] = A[len - 1];for (int x = 1; x < len; x++){B[x] = A[x-1];}A = B;i++;}return B;}

--

--

Charlie Chen (陳慶裕)
Charlie Chen (陳慶裕)

No responses yet