From b0d0679a6436360f15b1daa712f4564618ccf6e5 Mon Sep 17 00:00:00 2001 From: Hanting Wang <2696801449@qq.com> Date: Tue, 20 Oct 2026 15:24:50 +0800 Subject: [PATCH 1/2] Update A734.java --- src/com/hong/www/A734.java | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/com/hong/www/A734.java b/src/com/hong/www/A734.java index 9897656..608723c 100644 --- a/src/com/hong/www/A734.java +++ b/src/com/hong/www/A734.java @@ -1,5 +1,28 @@ package com.hong.www; +import java.util.*;; + public class A734 { - + public int networkDelayTime(int[][] times, int n, int k) { + HashMap> time=new HashMap<>(); + for(int[]x:times){ + if(time.containsKey(x[0])){ + ArrayList temp=time.get(x[0]); + temp.add(new int[]{x[1],x[2]}); + }else{ + time.put(x[0],new ArrayList(){{add(new int[]{x[1],x[2]});}}); + } + if(time.containsKey(x[1])){ + ArrayList temp=time.get(x[1]); + temp.add(new int[]{x[0],x[2]}); + }else{ + time.put(x[1],new ArrayList(){{add(new int[]{x[0],x[2]});}}); + } + } + int[] list=new int[n+1]; + for(int i=1;i<=n;i++){ + list[i]=Integer.MAX_VALUE; + } + return 0; + } } From 60ca41cf3476ce7bda6370e95dc81c9cc3466900 Mon Sep 17 00:00:00 2001 From: Hanting Wang <2696801449@qq.com> Date: Tue, 20 Oct 2026 17:01:41 +0800 Subject: [PATCH 2/2] Create A621.java --- src/com/hong/www/A621.java | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/com/hong/www/A621.java diff --git a/src/com/hong/www/A621.java b/src/com/hong/www/A621.java new file mode 100644 index 0000000..9d757a1 --- /dev/null +++ b/src/com/hong/www/A621.java @@ -0,0 +1,30 @@ +package com.hong.www; + +import java.util.*; + +public class A621 { + public int leastInterval(char[] tasks, int n) { + int[] temp = new int[n + 1]; + int[] res = new int[26]; + int max = 0; + ArrayList list = new ArrayList<>(); + for (char x : tasks) { + res[x - 'A']++; + } + /* + * for(HashMap.Entry x:task){ + * res[x.getKey()-'A']=x.getValue(); + * } + */ + for (int i=0; i<26; i++) { + if (res[i] > max) { + max = res[i]; + list.clear(); + } else if (res[i] == max) { + list.add((char) (i + 'A')); + } + } + int ans =(n+1)*(max-1)+list.size(); + return Math.max(ans, tasks.length); + } +}