401 data structures and algorithms code challenges
Create a new class AnimalShelter which holds only dogs and cats. The shelter operates using a first-in, first-out approach.
animal
animal
can be either a dog or a cat object.perf
pref
can be either "dog"
or "cat"
pref
is not "dog"
or "cat"
then return null
.none
cat
can be enqueued and dequeueddog
can be enqueued and dequeuedIf a cat or dog isn’t preferred, return whichever animal has been waiting in the shelter the longest.
My origional whiteboard didn’t work so I scrapped it and tried the method explained by JB to complete the challenge.