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

 

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

Given an ArrayList of numbers, find out if any numbers do not have their additive inverse (the result of multiplying by -1) present elsewhere in the list. For those numbers, add the additive inverse as the next element in the list after the first instance of the unmatched number. Return the modified list.


apcsaListAddNegations([-1]) → [-1, 1]
apcsaListAddNegations([2, -2]) → [2, -2]
apcsaListAddNegations([2, -2, 2]) → [2, -2, 2]

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

public ArrayList<Integer> apcsaListAddNegations(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: 320

Copyright Nick Parlante 2017 - privacy