954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

JAVA Expert Help me.. Write a function that accepts an array of integers and returns

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)

bc030400412
Newbie Poster
5 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

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

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You