当前位置:网站首页>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
边栏推荐
- 内卷、躺平与中年危机的相关思考
- applicationContext. Getbeansoftype obtains the execution methods of all implementation classes under an interface or obtains the operation application scenarios such as implementation class objects. L
- 歐洲家具EN 597-1 跟EN 597-2兩個阻燃標准一樣嗎?
- 测不准原理
- 05 MongoDB对列的各种操作总结
- The operating mechanism of spectrogram in audio Science
- 04 MongoDB各种查询操作 以及聚合操作总结
- django. core. exceptions. ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3
- 01 MongoDB的概述、应用场景、下载方式、连接方式和发展历史等
- MSc 307 (88) (2010 FTPC code) Part 5 low flame spread test
猜你喜欢
随机推荐
Building log analysis system with elk (III) -- Security Authentication
02 MongoDB数据类型、重要概念以及shell常用指令
一文告诉你什么是 Kubernetes
利用ELK 搭建日志分析系统(二)—— 部署安装
【MySQL】多表连接查询
黑體輻射初探
Elk builds log analysis system + Zipkin service link tracking integration
Several ways of sharing printers in LAN
友链须知
Detailed explanation of KVM common commands
ambari SSLError: Failed to connect. Please check openssl library versions.
Chapter 1 Introduction to bash
MSC 307(88) (2010 FTPC Code) Part 9床上用品试验
vscode中出现无法在只读编辑器中编辑
英语小记 - 表因果
仅用递归函数和栈操作逆序一个栈
11_刻意练习精讲
django. core. exceptions. ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3
单一职责原则
谈云原生,不得不谈的容器