Arrays: Left Rotation

  • + 0 comments

    C#

                var newlist = new List<int>(a);
    
        for(int i = 0; i< a.Count; i++){
            var index = i - d%a.Count;
    
    
            if(index >=0){
                newlist[index] = a[i];
                continue;
            }
    
            index += a.Count;
            newlist[index] = a[i];
    
    
        return newlist;
    }