406. Queue Reconstruction by Height
来源:互联网 发布:万人老虎机系统源码 编辑:程序博客网 时间:2024/06/16 12:56
题目大意:有一队人,每个人由一个(h,k)表示,h表示高度,k表示前面高于或等于自己的人个人。给一个打乱了的队列,求出正确的序列。
思路:
1.每次从队列中找出k=0,再在其中选出h最小的,加入到res队列中;然后对剩余队列做相应的处理;再循环,即可求出全部队列,类似于递归。176ms
2.先把队列按h从大到小,h相同则k从小到大的顺序排列,然后依次将每个人插入到res队列。83ms
CODE:
1.
2.
0 0
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- 406. Queue Reconstruction by Height
- Windows下mongodb安装和配置
- 【ide】myeclipse项目右键没有configure
- Memcached的使用
- Android学习之WebView
- Windows下bat脚本设置和获取环境变量
- 406. Queue Reconstruction by Height
- Windows计划任务执行时不显示窗口的问题
- java图片验证码包括文字和图片的旋转
- iOS的文件管理NSFileManager
- 约德尔测试
- python导出excel
- android官方侧滑菜单DrawerLayout详解
- UILabel自适应高度
- pip使用本地缓存文件来安装包