当前位置:网站首页>Problems with cat and dog queues
Problems with cat and dog queues
2022-06-28 04:06:00 【The roaring Conan】
Cat dog queue
【 subject 】
Pets 、 The categories of dogs and cats are as follows :

Implementation of a dog and cat queue structure , Requirements are as follows :
● Users can call add Methods will cat Class or dog Class to queue ;
● Users can call pollAll Method , Pop up all instances in the queue in the order of entering the queue ;
● Users can call pollDog Method , Queue up dog The instances of the class pop up in the order of entering the queue ;
● Users can call pollCat Method , Queue up cat The instances of the class pop up in the order of entering the queue ;
● Users can call isEmpty Method , Check if there are any in the queue dog or cat Example ;
● Users can call isDogEmpty Method , Check if there are any in the queue dog Class ;
● Users can call isCatEmpty Method , Check if there are any in the queue cat Class .
【 Ideas 】
This question examines the ability to implement special data structures and the ability to design algorithms for special functions .
This is an open type interview question , I hope the readers can have their own realization , Here are a few common design mistakes :
● cat Queue only cat example ,dog Queue only dog example , And then use a general queue to put all the instances . The reason for the error :cat、dog And the update of the general queue .
● Using hash table ,key It means a cat Example or dog example ,value Indicates the order in which this instance is queued . The reason for the error : An instance cannot be queued multiple times
边栏推荐
猜你喜欢

KVM常用命令详解

How to apply for ASTM E108 flame retardant test for photovoltaic panels?

ambari SSLError: Failed to connect. Please check openssl library versions.

Chapter 1 Introduction to bash

加法器—笔记

PyCharm设置仿sublime配色方案

Staggered and permutation combination formula

错排兼排列组合公式

Door level modeling - learning notes

vscode中出现无法在只读编辑器中编辑
随机推荐
解析STEAM教育框架下未来教师研究能力
Pychart shares third-party modules among different projects
Detailed explanation of iptables firewall rules and firewalld firewall rules
利用 telegraf influxdb grafana 搭建服务器监控平台
@Several scenarios of transactional failure
[graduation season] graduate summary
Two methods of shell script parameter passing based on arm5718
Open the field of maker education and creation
leetcode:494. All methods of adding and subtracting operators to the array to get the specified value
What is the process of en 1101 flammability test for curtains?
Door level modeling - learning notes
月赛补题
How to modify a se38 editor theme
谈云原生,不得不谈的容器
Notes to friendship chain
内卷、躺平与中年危机的相关思考
关于 SY8120I 的DC-DC的降压芯片的学习(12V降至3.3V)
猫狗队列的问题
A solution to the inefficiency of setting debug mode in developing flask framework with pychar
欧洲家具EN 597-1 跟EN 597-2两个阻燃标准一样吗?