Update appNew update is available. Click here to update.
About
Integral University 2025
My Stats
EXP gained
yellow-spark
2847
Level
5 (Champion)
Community stats
Discussions
0
Upvotes
1
Know more
Weekend contest rating
Contest attended
Problems solved
2021 2023
Better than %
Weekend contest rating
Contest attended
Problems solved
2021 2023
Better than %
53
Total problems solved
43
Easy
10
Moderate
0
Hard
0
Ninja
Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov Dec Dec

Current streak:

0 days

Longest streak:

6 days

Less

More

Achievements
1
Ronin
Topics
Arrays
Discussions
JAVA CODE
Interview problems

public class Solution {

        public static int[] moveZeros(int n, int []a) {

        // Write your code here.

        int j=0;

        for(int i=0;i<n;i++){

            if(a[i]!=0){

                a[j++]=a[i];

            }

        }

        while(j<n){

            a[j++]=0;

        }return a;

    }

}

profile
shadab rehan
Published On 15-Sep-2023
68 views
0 replies
0 upvotes
JAVA CODE
Interview problems

public class Solution {

        public static int[] moveZeros(int n, int []a) {

        // Write your code here.

        int j=0;

        for(int i=0;i<n;i++){

            if(a[i]!=0){

                a[j++]=a[i];

            }

        }

        while(j<n){

            a[j++]=0;

        }return a;

    }

}

profile
shadab rehan
Published On 15-Sep-2023
68 views
0 replies
0 upvotes
(JAVA) 100% OPTIMISED CODE
Interview problems

import java.util.* ;

class Solution {

    

    public static void main(String args[]){

        Scanner br = new Scanner(System.in);

        int n = br.nextInt();

        int[] array = new int[n];

        for(int i=0;i<n;i++){

            array[i]=br.nextInt();

        }       

        int k=br.nextInt();

 

        int[] soln= new int[n];

        for(int i=0;i<n;i++){

            soln[i]=array[(i+k)%n];

        }

        for(int i=0;i<n;i++){

            System.out.print(soln[i]+" ");

        }

    }

}

profile
shadab rehan
Published On 14-Sep-2023
108 views
0 replies
0 upvotes
(JAVA) 100% OPTIMISED CODE
Interview problems

import java.util.* ;

class Solution {

    

    public static void main(String args[]){

        Scanner br = new Scanner(System.in);

        int n = br.nextInt();

        int[] array = new int[n];

        for(int i=0;i<n;i++){

            array[i]=br.nextInt();

        }       

        int k=br.nextInt();

 

        int[] soln= new int[n];

        for(int i=0;i<n;i++){

            soln[i]=array[(i+k)%n];

        }

        for(int i=0;i<n;i++){

            System.out.print(soln[i]+" ");

        }

    }

}

profile
shadab rehan
Published On 14-Sep-2023
108 views
0 replies
0 upvotes
Optimized java solution
Interview problems

public class Solution {

    public static void insertionSort(int[] arr, int size) {

        //Your code goes here

        int temp=0,j=0;

        for(int i=0;i<size-1;i++){

               j=i+1;

            if(j<size && arr[j]<arr[i]){

                    temp=arr[i];

                    arr[i]=arr[j];

                    arr[j]=temp;

                    insertionSort(arr, size-1);

            }

        }

    }

}

profile
shadab rehan
Published On 02-Sep-2023
48 views
0 replies
1 upvotes
Optimized java solution
Interview problems

public class Solution {

    public static void insertionSort(int[] arr, int size) {

        //Your code goes here

        int temp=0,j=0;

        for(int i=0;i<size-1;i++){

               j=i+1;

            if(j<size && arr[j]<arr[i]){

                    temp=arr[i];

                    arr[i]=arr[j];

                    arr[j]=temp;

                    insertionSort(arr, size-1);

            }

        }

    }

}

profile
shadab rehan
Published On 02-Sep-2023
48 views
0 replies
1 upvotes