Rotate Array Left N-times c#:
more at siccolo blurbs
public static int[] RotateArrayLeft(int[] ins, int startindex = 1)
{
if (ins == null || ins.Length == 0) { return ins; }
var outs = new int[ins.Length];
//Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length):
Array.Copy(ins, startindex, outs, 0, ins.Length - startindex);
var q = new Queue(ins);
for (int i = outs.Length - startindex; i < outs.Length; i++)
{
outs[i] = q.Dequeue();
}
return outs;
}
more at siccolo blurbs
No comments:
Post a Comment