
- class Solution {
- public boolean lemonadeChange(int[] bills) {
- int fiveCount = 0;
- int tenCount = 0;
-
- for(int i=0;i
- if(bills[i] == 5){
- fiveCount++;
- }else if(bills[i] == 10){
- fiveCount--;
- tenCount++;
- }else{
- if(tenCount>0){
- tenCount--;
- fiveCount--;
- }else{
- fiveCount-=3;
- }
- }
-
- if(fiveCount<0 || tenCount<0){
- return false;
- }
- }
-
- return true;
- }
- }

- class Solution {
- public int[][] reconstructQueue(int[][] people) {
- //按身高进行排序
- Arrays.sort(people, (o1, o2) -> {
- if(o1[0] != o2[0]){
- return o2[0] - o1[0];
- }else{
- return o1[1] - o2[1];
- }
- });
-
- ArrayList<int[]> result = new ArrayList<>();
- for(int i=0;i
- result.add(people[i][1],people[i]);
- }
-
- return result.toArray(new int[people.length][2]);
- }
- }
- class Solution {
- public int monotoneIncreasingDigits(int n) {
- if(n<10){
- return n;
- }
-
- char[] chars = (n + "").toCharArray();
- for(int i=chars.length-1;i>=1;i--){
- if(chars[i]
1]){ - for(int j=i;j
- chars[j] = '9';
- }
- chars[i-1] = (char)(chars[i-1] - 1);
- }
- }
-
- return Integer.valueOf(new String(chars));
- }
- }
-
相关阅读:
高性能音乐流媒体服务Diosic
golang 求立方根
canvas绘制扫描图
Windows 无法访问wsl ubuntu 中 docker 的端口
L2-052 吉利矩阵
一种无需调查船上坞的调查设备安装测量方法和安装测量系统
Letter shell移植到AT32WB415
HarmonyOS 3.1 第三方包导入
深度学习的发展历程与未来展望
c语言malloc不初始化,为什么没有占用系统空闲内存
-
原文地址:https://blog.csdn.net/qq_15802379/article/details/139710384