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

 

apcsaListAddLargestIndex


Given an ArrayList of Integers called lst, add a new element to the end, the value of which is the index of the largest element in the ArrayList. Return the ArrayList as output.


If the largest element in the List occurs more than once, only add one element to the end of the list with the index of where the largest element occurs first (lowest index).
HINT
You will need to use a loop here, but the methodology will be slightly different from the last problem.

apcsaListAddLargestIndex([3, 4, 5]) → [3, 4, 5, 2]
apcsaListAddLargestIndex([1, 2, 4, 5, 6, 10]) → [1, 2, 4, 5, 6, 10, 5]
apcsaListAddLargestIndex([5, 0, 3]) → [5, 0, 3, 0]

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

public ArrayList<Integer> apcsaListAddLargestIndex(ArrayList<Integer> lst) { }

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: 230

Copyright Nick Parlante 2017 - privacy