Biggest Pair
Premium Content - Free Preview
The people of Zumbania share a lot with their next-door neighbors, so wealth can be measured by looking at pairs of people. You would like to find the richest pair on each street in Zumbania.
End of Free Content Preview. Please Sign in or Sign up to buy premium content.
Comments
Peter Fekete
Apr 16, 7:35 AMat first I misunderstood the challange and was searching for consecutive numbers like 4+5 and 2+3 but didnt realize only the indexes in array need to be consecutive 30+70 wouldnt work...
https://www.learneroo.com/user_answers/6874565726
Would someone take a look at my code? What I am specifically having trouble is this: I seem to not be storing the correct value for the biggest
pair sum, which I have called "biggest". I've fiddled with the for loop, which I realize might seem a bit unconventional (starting at i = 2 instead of i = 0), but I'm not worried about that part. My loop seems to run to the end and compare values only near the end, so I can't seem to return the correct values for the first two test cases as the correct value is somewhere near the middle. Is there something I could be doing to better update the value for "biggest"?
thales
Jul 18, 1:24 PMa solution:
my code
Weasel Bandit
Nov 21, 5:44 PMThis code keeps timing out. Can someone tell me if it would work if it didn't?
https://www.learneroo.com/user_answers/4065805762
Learneroo
Nov 21, 11:40 PMYour piece
i=i++
should bei++
.ilse
Jan 6, 3:24 PMI don't understand this error message.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6
at Main.doStuff(Main.java:7)
at Main.main(Main.java:27)
my code
Learneroo
Jan 7, 7:12 PMIt means you're trying to call an index in an array that is outside the bounds (or size) of the array. What would happen when you reach this line when you're already up to the last item?
sum = ar[i] + ar[i+1];