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.
Peter FeketeApr 16, 7:35 AM
at 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...
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"?
thalesJul 18, 1:24 PM
Weasel BanditNov 21, 5:44 PM
This code keeps timing out. Can someone tell me if it would work if it didn't?
LearnerooNov 21, 11:40 PM
ilseJan 6, 3:24 PM
I don't understand this error message.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6
LearnerooJan 7, 7:12 PM
It 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];