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

 

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

An array list contains a list of pets that are following each other to a big pet party. The pet at position 0 is following the pet at position 1. If the pet is a cat that is being followed by a dog, it gets scared and runs away, so you should remove it from the array list. Return the array list of pets.


listScaredyCat(["cat", "dog", "guinea pig"]) → ["cat", "dog", "guinea pig"]
listScaredyCat(["cat", "frog", "cat", "dog", "cat"]) → ["cat", "frog", "cat", "dog"]
listScaredyCat(["cat", "dog", "cat", "cat", "snake"]) → ["cat", "dog", "snake"]

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

public List<String> listScaredyCat(List<String> petsList) { }

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

Copyright Nick Parlante 2017 - privacy