Skip to content

Partially accepted Solution  #1

@NinzaRJ01

Description

@NinzaRJ01

int t;/*TestCases */
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
t = Integer.parseInt(br.readLine());
for(int k=0;k<t;k++){//O(n ^ 2)
int n;int[] B ;String[] s;/* SizeOfArray,Resultant Array, Temporay Array */
Scanner sc;//Scanner
n = Integer.parseInt(br.readLine());
sc = new Scanner(br);
B = new int[n];
for(int i=0;i<n;i++){// Contain Program to find all ith element of B using A
int key = sc.nextInt();
if(i!=0){
B[i] = (int) Math.ceil((double)B[i-1]/key)*key;
}else B[i]=key;
}
for(int i:B)
System.out.print(i+" ");
System.out.println();
sc.close();
}

Here my solution is only partially accepted(pass 7 test cases) in problem statement HackerEarthProblemNon-Increasing Array
And i won't able to find a way to optimise my code or any other accepted solution written in java for this particular problem that pass these tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions