JAVA Expert Help me.. Write a function that accepts an array of integers and returns
Expand Post »
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
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.