tag:blogger.com,1999:blog-658693724588200643.post6369533153170643921..comments2023-06-29T05:34:40.125-07:00Comments on DotNetPeople: Codility Cyclic Rotation Solution C#jatinhttp://www.blogger.com/profile/12823525541194838677noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-658693724588200643.post-7116953620512743752016-09-28T13:08:30.255-07:002016-09-28T13:08:30.255-07:00class Solution {
public int[] solution(int[] A...class Solution {<br /> public int[] solution(int[] A, int K) {<br /> // write your code in C# 6.0 with .NET 4.5 (Mono)<br /> for (var i = 0; i < K; i++) {<br /> for (var j = A.Length - 1; j > 0; j--) {<br /> var temp = A[j];<br /> A[j] = A[j-1];<br /> A[j-1] = temp;<br /> }<br /> }<br /> returnLucianuhttps://www.blogger.com/profile/11332003455389288339noreply@blogger.comtag:blogger.com,1999:blog-658693724588200643.post-86920846571512869692016-05-18T03:03:14.475-07:002016-05-18T03:03:14.475-07:00@nymarco - Thanks for your input. But I have teste...@nymarco - Thanks for your input. But I have tested the solution in codility and the result is also pasted.jatinhttps://www.blogger.com/profile/12823525541194838677noreply@blogger.comtag:blogger.com,1999:blog-658693724588200643.post-25361411342098255682016-05-18T01:23:08.735-07:002016-05-18T01:23:08.735-07:00Seems like the constraint: "each element of a...Seems like the constraint: "each element of array A is an integer within the range [−1,000..1,000]." have not effect in the solution.<br />I would definitely use LinQ if that's okay:<br />A.Skip((K-1) % A.Length).Concat(A.Take((K-1) % A.Length))<br />The modulus controls multiple turnaraounds of the array. The K-1 is cueing so the result example is correct. <br /><br />BTW: The nymarcohttps://www.blogger.com/profile/03183827432505085348noreply@blogger.com