id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

orion.a.smith@gmail.com apcsa-arrays > apcsaArraysAddLargerOfPair
prev  |  next  |  chance

This function adds the larger of each pair of values in the array. The first pair is elements with index 0 and 1, the second pair is the elements with values 2 and 3, and so on. Return the sum of each of these larger values.

HINT
use Math.max(v1,v2) to find the larger, or just use > and an if/else.

apcsaArraysAddLargerOfPair([1, 2, 3, 4, 5, 6]) → 12
apcsaArraysAddLargerOfPair([3, 2, -5, 0]) → 3
apcsaArraysAddLargerOfPair([2, 1]) → 2

...Save, Compile, Run (ctrl-enter)

public int apcsaArraysAddLargerOfPair(int[] nums) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 240

Copyright Nick Parlante 2017 - privacy