This commit is contained in:
Mrhongxing committed 2026-10-27 01:41:25 +08:00
1 parent e689983a1d
commit 6e84c2590b
3 files changed
+77

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
package com.hong.www;
import java.util.*;
public class A1642 {
public int furthestBuilding(int[] heights, int bricks, int ladders) {
ArrayList<int[]> temp=new ArrayList<>();
int now=heights[0];
PriorityQueue<Integer> history=new PriorityQueue<>((a,b)->b-a);
for(int x=0;x<heights.length;x++){
if(now<heights[x]){
temp.add(new int[]{heights[x]-now,x});
}
now=heights[x];
}
for(int x=0;x<temp.size();x++){
if(bricks>=temp.get(x)[0]){
history.offer(temp.get(x)[0]);
bricks-=temp.get(x)[0];
}else{
if(ladders>0){
if(!history.isEmpty()){
int max=history.peek();
if(max>temp.get(x)[0]){
bricks+=history.poll();
bricks-=temp.get(x)[0];
history.offer(temp.get(x)[0]);
}
}
ladders--;
}else{
return temp.get(x)[1]-1;
}
}
}
return heights.length-1;
}
public static void main(String[] args) {
A1642 a1642=new A1642();
int[] heights={4,2,7,6,9,14,12};
int bricks=5;
int ladders=1;
System.out.println(a1642.furthestBuilding(heights,bricks,ladders));
}
}
+23
View File
@@ -0,0 +1,23 @@
package com.hong.www;
public class A85 {
public int maximalRectangle(char[][] matrix) {
int[] temp=new int[matrix[0].length];
A84 xxx=new A84();
int count=0;
for(char[] x:matrix){
for(int y=0;y<x.length;y++){
if(x[y]=='1'){
temp[y]++;
}else{
temp[y]=0;
}
}
int xx=xxx.largestRectangleArea(temp);
if(xx>count){
count=xx;
}
}
return count;
}
}
+9
View File
@@ -0,0 +1,9 @@
package com.hong.www;
public class LCR162 {
public int digitOneInNumber(int num) {
char[] chars = String.valueOf(num).toCharArray();
return 0;
}
}