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

 

stacks_pushIt


stacks_pushIt--Salt and Peppa came out with a hit single in 1987 called "Push it". If you haven't checked out the song, I highly suggest it.

This method takes a String array as a single parameter, and returns a Integer stack.

Iterate through the String array and every index that holds the value of either "Salt" or "Peppa" you should push the index number into the stack to be returned.

If you come across a String value of "Real Good" you should then pop the top value out of the Stack.


stacks_pushIt(["Salt", "Peppa", "Biggie", "Salt"]) → [0, 1, 3]
stacks_pushIt(["Salt", "Peppa", "Real Good", "Salt"]) → [0, 3]
stacks_pushIt(["Ice Cube", "Real Good", "Tupac", "Salt"]) → [3]

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

public Stack<Integer> stacks_pushIt(String [] names){ }

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

Post-solution available

Copyright Nick Parlante 2017 - privacy