Construct animal queue that consists of the following features:
- Contains Cats and Dogs
- If not preference on animal type is needed, then fetch the animal that was placed first in the queue
- If Cat is needed then fetch the Cat that was added first
- If Dog is needed then fetch the Dog that was added first
This is an interesting real-world use of Queue data structure and is well discussed in several coding and algorithm books, including Cracking the coding Interview, and several other coding forums - Page1 A collection of hundreds of interview questions and solutions are available in our blog at Interview Question
Solution
No comments:
Post a Comment