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

 

apcsaListAddBeginning


Given an ArrayList of Integers called lst, add a new element num at the beginning of the ArrayList. Return the ArrayList as output.

HINT
The add method with two parameters uses the first parameter as the new index.

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

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

public ArrayList<Integer> apcsaListAddBeginning(ArrayList<Integer> lst, int num) { }

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