Help me in solving DIVCOL problem

My issue

give me the approach to solve this question\

My code

import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t --> 0){
		    int n =  sc.nextInt();
		    int[] arr = new int[n];
		    for(int i=0; i<n; i++){
		        arr[i] = sc.nextInt();
		    }
		    int sum= Integer.MAX_VALUE;
		    for(int i=0; i<n; i++){
		        if(arr[i]<sum){
		            sum = arr[i];
		        }
		        System.out.println(sum);
		    }
		}

	}
}

Problem Link: Non-Divisor Array Practice Coding Problem

First Read the problem properly ,the question ask to take only n as input.

1 Like