From 6e84c2590b10b8d61466d28fea437cc80c3a6051 Mon Sep 17 00:00:00 2001 From: Mrhongxing <154480715+Mrhongxing@users.noreply.github.com> Date: Tue, 27 Oct 2026 01:41:25 +0800 Subject: [PATCH] 1.7 --- src/com/hong/www/A1642.java | 45 ++++++++++++++++++++++++++++++++++++ src/com/hong/www/A85.java | 23 ++++++++++++++++++ src/com/hong/www/LCR162.java | 9 ++++++++ 3 files changed, 77 insertions(+) create mode 100644 src/com/hong/www/A1642.java create mode 100644 src/com/hong/www/A85.java create mode 100644 src/com/hong/www/LCR162.java diff --git a/src/com/hong/www/A1642.java b/src/com/hong/www/A1642.java new file mode 100644 index 0000000..3d8996c --- /dev/null +++ b/src/com/hong/www/A1642.java @@ -0,0 +1,45 @@ +package com.hong.www; + +import java.util.*; + +public class A1642 { + public int furthestBuilding(int[] heights, int bricks, int ladders) { + ArrayList temp=new ArrayList<>(); + int now=heights[0]; + PriorityQueue history=new PriorityQueue<>((a,b)->b-a); + for(int x=0;x=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)); + } +} diff --git a/src/com/hong/www/A85.java b/src/com/hong/www/A85.java new file mode 100644 index 0000000..93d87bd --- /dev/null +++ b/src/com/hong/www/A85.java @@ -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;ycount){ + count=xx; + } + } + return count; + } +} diff --git a/src/com/hong/www/LCR162.java b/src/com/hong/www/LCR162.java new file mode 100644 index 0000000..6e51932 --- /dev/null +++ b/src/com/hong/www/LCR162.java @@ -0,0 +1,9 @@ +package com.hong.www; + +public class LCR162 { + public int digitOneInNumber(int num) { + char[] chars = String.valueOf(num).toCharArray(); + + return 0; + } +}