当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
Door level modeling - learning notes
英语小记 - 表因果
Pycharm不同项目之间共用第三方模块
数字电路学习笔记(一)
第一个.net core MVC项目
Meichuang data security management platform has obtained the evaluation certificate of "data security product capability verification plan" of the Institute
一千行 MySQL 学习笔记,值得收藏!
Learning notes of digital circuit (II)
Does the applet image component not display pictures?
@Transactional失效的几种场景
03 MongoDB文档的各种增加、更新、删除操作总结
02 MongoDB数据类型、重要概念以及shell常用指令
04 MongoDB各种查询操作 以及聚合操作总结
错排兼排列组合公式
Building log analysis system with elk (II) -- deployment and installation
A preliminary study of blackbody radiation
ambari SSLError: Failed to connect. Please check openssl library versions.
KVM常用命令详解
sqlserver 数据库之事物使用入门 案例
利用ELK 搭建日志分析系统(二)—— 部署安装







