From b3c7a28b1cd45305c33377cc8dec8b3fa6bc61f7 Mon Sep 17 00:00:00 2001 From: Mrhongxing <154480715+Mrhongxing@users.noreply.github.com> Date: Tue, 13 Oct 2026 02:01:30 +0800 Subject: [PATCH] 0.2 --- src/com/hong/www/A135.java | 32 ++++++++++++++++ src/com/hong/www/A30.java | 78 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 src/com/hong/www/A135.java create mode 100644 src/com/hong/www/A30.java diff --git a/src/com/hong/www/A135.java b/src/com/hong/www/A135.java new file mode 100644 index 0000000..11105b3 --- /dev/null +++ b/src/com/hong/www/A135.java @@ -0,0 +1,32 @@ +package com.hong.www; + +import java.util.*; + +public class A135 { + public int candy(int[] ratings) { + int temp=-1; + int[] counts=new int[ratings.length]; + Arrays.fill(counts,1); + for(int i=1;iratings[i-1]){ + counts[i]=counts[i-1]+1; + } + } + for(int i=ratings.length-2;i>=0;i--){ + if(ratings[i]>ratings[i+1]&&counts[i]<=counts[i+1]){ + counts[i]=counts[i+1]+1; + } + } + + int currect=0; + for(int x:counts){ + currect+=x; + } + return currect; + } + public static void main(String[] args) { + A135 solution = new A135(); + int[] ratings = {1, 3, 2,2,1}; + System.out.println(solution.candy(ratings)); + } +} diff --git a/src/com/hong/www/A30.java b/src/com/hong/www/A30.java new file mode 100644 index 0000000..40d1191 --- /dev/null +++ b/src/com/hong/www/A30.java @@ -0,0 +1,78 @@ +package com.hong.www; + +import java.util.*; + +public class A30 { + /* + * public void aaa(int time, String[] words,ArrayList temp){ + * time++; + * if(time==words.length+1){ + * + * }else{ + * ArrayList temp1 = new ArrayList<>(); + * for() + * } + * } + */ + public List findSubstring(String s, String[] words) { + /* + * int time=0; + * ArrayList temp = new ArrayList<>(); + * aaa(time,words,temp); + * + * List result = new ArrayList<>(); + * for(String x:words){ + * temp.setLength(0); + * } + */ + char[] a = s.toCharArray(); + HashMap temp = new HashMap<>(); + List result = new ArrayList<>(); + HashSet temp1 = new HashSet<>(); + for(String x:words){ + temp.put(x, 0); + } + int left=0; + int right=words[0].toCharArray().length+left; + StringBuilder sb = new StringBuilder(); + int time=0; + int time1=0; + while (right