my code is perfect but I do not get the efficient code it is of the order of an o(n^2) …can you plz give me an efficient code
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(1 <= n && n <= 1000)
{
int[] arr = new int[n];
for(int i =0 ;i <n ;i++)
{
arr[i] = sc.nextInt();
}
int t = sc.nextInt();
target(arr,t);
}
}
public static void target(int[] arr, int t)
{
for(int i =0 ; i < arr.length -1 ;i++)
{
for(int j = i+1 ; j < arr.length ; j++)
{
if( arr[i] + arr[j] == t )
{
System.out.print(arr[i] +" and "+arr[j]);
System.out.println();
}
}
}
}