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

 

frew@mclean.com apcs2025unit4aalgs > duplicates
prev  |  next  |  chance

Find the integers that exist in both arrays and add them to a new array. Elements in the new array should be in the same relative order they are found in the first parameter array. There will not be duplicate values within each individual parameter array.


duplicates([1, 2, 3, 4, 5, 6, 7, 8, 9], [12, 34, 2, 46, 4, 7, 3, 55]) → [2, 3, 4, 7]
duplicates([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) → [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
duplicates([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [5, 10, 15, 20, 25, 30, 35, 40]) → [5, 10, 15, 20]

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

public int[] duplicates(int[] arr1, int[] arr2) { }

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

Copyright Nick Parlante 2017 - privacy