Write a function that accepts an array of integers and returns the second largest integer in the array. Return -1 if there is no second largest.

The signature of the function is

public class bc
{
public static void main(String[] args){ }
int f(int[ ] a) { }


}

Examples:

if the input array is {1, 2, 3, 4}      return       3
if the input array is {{4, 1, 2, 3}}        return    3
if the input array is {1, 1, 2, 2}        return         1
if the input array is {1, 1}          return        -1
if the input array is {1}            return              -1
if the input array is {}                 return              -1

bc.java (Required code)

Just post your code and ask about the parts you don't understand. All you have posted here is your assignment.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.