Integral University 2025
My Stats
EXP gained
2847
Level
5 (Champion)
Community stats
Discussions
0
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

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;

}

}

Published On 15-Sep-2023
68 views
0 replies
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;

}

}

Published On 15-Sep-2023
68 views
0 replies
(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]+" ");

}

}

}

Published On 14-Sep-2023
108 views
0 replies
(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]+" ");

}

}

}

Published On 14-Sep-2023
108 views
0 replies
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);

}

}

}

}

Published On 02-Sep-2023
48 views
0 replies
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);

}

}

}

}