From feda21c8d6494910d3a955954170bffe87797771 Mon Sep 17 00:00:00 2001 From: Cool <747682928@qq.com> Date: Mon, 23 Sep 2024 22:18:58 +0800 Subject: [PATCH] =?UTF-8?q?2024/9/23=20LeetCode=20Hot100=20=E8=B4=AA?= =?UTF-8?q?=E5=BF=83=E7=BB=93=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cool/hot100/greedy/Num45.java | 32 +++++++++++++++++ .../java/com/cool/hot100/greedy/Num763.java | 36 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 src/main/java/com/cool/hot100/greedy/Num45.java create mode 100644 src/main/java/com/cool/hot100/greedy/Num763.java diff --git a/src/main/java/com/cool/hot100/greedy/Num45.java b/src/main/java/com/cool/hot100/greedy/Num45.java new file mode 100644 index 0000000..567ed8b --- /dev/null +++ b/src/main/java/com/cool/hot100/greedy/Num45.java @@ -0,0 +1,32 @@ +package com.cool.hot100.greedy; + +import org.junit.Test; + +/** + * Created with IntelliJ IDEA. + * + * @Author: Cool + * @Date: 2024/09/23/20:47 + * DayNumber 1 + * Hard 2 + * Level 6 + */ +public class Num45 { + public int jump(int[] nums) { + int end=0; + int maxDistance=0; + int res=0; + for(int i=0;i partitionLabels(String s) { + int[] last = new int[26]; + for (int i = 0; i < s.length(); i++) { + last[s.charAt(i) - 'a'] = i; + } + int end=0; + int start=0; + List res=new ArrayList<>(); + for (int i = 0; i < s.length(); i++) { + end=Math.max(end,last[s.charAt(i)-'a']); + if(end==i){ + res.add(end-start+1); + start=i+1; + } + } + return res; + } + +}