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

 

orion.a.smith@gmail.com apcsa-lists > apcsaListAddRepeat
prev  |  next  |  chance

Given an ArrayList of Integers called lst, add a new element at position pos, with the same value as the old element at pos. Thus, if pos is 0 and the element at index 0 has the value 3, your code would insert an additional Integer element with the value 3 such that the first two elements both now have the value 3. Return the ArrayList as output.


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

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

public ArrayList<Integer> apcsaListAddRepeat(ArrayList<Integer> lst, int pos) { }

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

Copyright Nick Parlante 2017 - privacy