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

 

orion.a.smith@gmail.com apcsa-arrays > apcsaArraysFindShared
prev  |  next  |  chance

Heads up, this is a harder problem. Huzzah!


Given two arrays of ints arr1 and arr2, create and return an output array containing only the int values that are the same in both inputs.  The order of the output values should be determined by the order in which they are found in arr1.

HINT: this problem definitely involves more than one loop.

CHALLENGE: solve in one line.  Yes, it's possible - I think.

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

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

public int[] apcsaArraysFindShared(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: 260

Copyright Nick Parlante 2017 - privacy