Arrays: Left Rotation

  • + 0 comments

    Solution for c#.

    public static List<int> rotLeft(List<int> a, int d)
    {
    	int n = a.Count;
    	int rotateBy = d % n;
    
    	List<int> rotatedPart = a.GetRange(0, rotateBy);
    	a.RemoveRange(0, rotateBy);
    	a.AddRange(rotatedPart);
    
    	return a;
    
    }