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

 

konstans@stuy.edu set1 > arrayFirstDuplicate
prev  |  next  |  chance

Return the first word in the words array that is the same as another word in the array. If there are no duplicate elements, then return the last word in the array. The words array will contain at least one word.


arrayFirstDuplicate(["jet", "golf", "hi", "golf", "kid"]) → "golf"
arrayFirstDuplicate(["jet", "golf", "hi", "golf", "jet", "lol"]) → "jet"
arrayFirstDuplicate(["jet", "golf", "hi", "lol"]) → "lol"

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

public String arrayFirstDuplicate(String[] words) { }

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: 10 Post-solution available

Copyright Nick Parlante 2017 - privacy