class Solution{
// Function to find largest and second largest element in the array
public static ArrayList<Integer> largestAndSecondLargest(int sizeOfArray, int arr[])
{
//code here.
int largest=-1;
int sec_largest=-1;
for(int i=0;i<sizeOfArray;i++)
{
largest = Math.max(largest,arr[i]);
}
for(int i=0;i<sizeOfArray;i++)
{
if(arr[i]<largest)
{
sec_largest= Math.max(sec_largest,arr[i]);
}
}
ArrayList<Integer> al = new ArrayList<Integer>(2);
al.add(largest);
al.add(sec_largest);
return al;
}
}
}