Sort by

recency

|

92 Discussions

|

  • + 0 comments

    I have written this using simple basics if you know best way to solve pls comment below : )

    def rotateLeft(d, arr):
        dro=list(arr[i] for i in range(d))
        for i in dro:
            arr.remove(i)
        x=arr+dro
        print(*x)
    if __name__ == '__main__':
        first_multiple_input = input().rstrip().split()
        n = int(first_multiple_input[0])
        d = int(first_multiple_input[1])
        arr = list(map(int, input().rstrip().split()))
        rotateLeft(d, arr)
    
  • + 0 comments

    Python

    n, d = map(int,input().split(' '))
    arr = list(map(int,input().split(' ')))
    # spliting array into two parts
    y = arr[:d:]
    z = arr[d::]
    # extending second list with first list instead of using for loop.
    z.extend(y)
    #unpacking list to string items
    print(*z)
    
  • + 0 comments

    python solution

    n, d = map(int,input().split(' '))
    arr = list(map(int,input().split(' ')))
    for i in range(n):
        print(arr[(d+i)%n],end=' ')
    
  • + 0 comments

    My javascript solution

    function processData(input) {
        const oprCount = input.split('\n')[0].split(' ')[1];
        let arr = input.split('\n')[1].split(' ');
    
        arr.push(...arr.splice(0,oprCount));
    
        console.log(arr.join(' '));
    }
    
  • + 0 comments

    whats wrong in my program

    import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;

    public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[]arr= new int[n]; for(int i=0;i

    }
    public static void rotate(int[]arr ,int d)
    {
        int temp;
        for(int i=0;i<d;i++)
        {
            temp=arr[0];
            for(int j=0;j<arr.length-1;j++)
            {
                arr[j]=arr[j+1];
            }arr[arr.length-1]=temp;
        }
    }
    public static void display(int[]arr)
    {
        for(int i=0;i<arr.length;i++)
        System.out.print(arr[i]+" ");
    }
    

    }