当前位置: 首页 > news >正文

Java | Leetcode Java题解之第406题根据身高重建队列

题目:

题解:

class Solution {public int[][] reconstructQueue(int[][] people) {Arrays.sort(people, new Comparator<int[]>() {public int compare(int[] person1, int[] person2) {if (person1[0] != person2[0]) {return person2[0] - person1[0];} else {return person1[1] - person2[1];}}});List<int[]> ans = new ArrayList<int[]>();for (int[] person : people) {ans.add(person[1], person);}return ans.toArray(new int[ans.size()][]);}
}
http://www.lryc.cn/news/438555.html

相关文章:

  • 安卓获取apk的公钥,用于申请app备案等
  • 【leetcode_python】杨辉三角
  • Parallels Desktop 20 for Mac中文版发布了?会哪些新功能
  • SpringBoot整合SSE-灵活管控连接
  • 挖矿木马-Linux
  • 【leetcode——415场周赛】——python前两题
  • 【CSS in Depth 2 精译_029】5.2 Grid 网格布局中的网格结构剖析(上)
  • ZYNQ LWIP(RAW API) TCP函数学习
  • Spring Boot,在应用程序启动后执行某些 SQL 语句
  • 【SQL】百题计划:SQL最基本的判断和查询。
  • 04_Python数据类型_列表
  • F5设备绑定EIP
  • 使用 PyCharm 新建 Python 项目详解
  • 从0开始学习 RocketMQ:分布式事务消息的实现
  • MySQL 查询数据库的数据总量
  • [C++]——vector
  • 自动驾驶:LQR、ILQR和DDP原理、公式推导以及代码演示(七、CILQR约束条件下的ILQR求解)
  • 随想录笔记-二叉树练习题
  • 华雁智科前端面试题
  • 【iOS】单例模式
  • Linux | 探索 Linux 信号机制:信号的产生和自定义捕捉
  • 递归的时间复杂度分析
  • C++: 二叉树进阶面试题
  • 【HarmonyOS NEXT】实现网络图片保存到手机相册
  • Pytorch详解-数据模块
  • 浅谈openresty
  • 【学习笔记】2024最新版SpringCloud教程
  • Proxyless Service Mesh:下一代微服务架构体系
  • 大数据Flink(一百一十八):SQL水印操作(Watermark)
  • 【QGC】把QGroundControl地面站添加到Ubuntu侧边菜单栏启动