登录
  • #刷题
  • #careercup

【第三轮】7.7-7.13 CareerCup 3.7

wrj5518
1909
16
3.7 An animal shelter holds only dogs and cats, and operates on a strictly "first in, first out" basis. People must adopt either the "oldest" (based on arrival time) of all animals at the shelter, or they can select whether they would prefer a dog or a cat (and will receive the oldest animal of that type). They cannot select which specific animal they would like. Create the data structures to maintain this system and implement operations such as enqueue, dequeueAny, dequeueDog and dequeueCat.You may use the built-in LinkedList data structure.

回复解法可以按照以下格式来

[indent]
【解题思路】

【时间复杂度】

【空间复杂度】

【gist link】

---------------Optional,如果觉得test case比较好,欢迎写出来分享----------------------

【test case】


[/indent]


Notice:

1、记得在程序注释中表明自己算法的时间、空间复杂度

2、代码难懂之处加注释

3、每道题目有对应的帖子,除了贴解法,欢迎讨论,集思广益

4、任何未尽之处,欢迎回报名帖提问,我会进一步作出修改。
16条回复
热度排序

发表回复