From eeaac8389ca21bb49dfd71a2d985cbcf85619436 Mon Sep 17 00:00:00 2001
From: Cool <747682928@qq.com>
Date: Fri, 18 Oct 2024 12:37:33 +0800
Subject: [PATCH] =?UTF-8?q?2024/10/18=20=E7=81=B5=E8=8C=B6=E9=A2=98?=
 =?UTF-8?q?=E5=8D=95=20=E4=B8=8D=E5=AE=9A=E9=95=BF=E6=BB=91=E5=8A=A8?=
 =?UTF-8?q?=E7=AA=97=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../sliding_windows/Num1208.java              | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 src/main/java/com/cool/ling_cha_mount/sliding_windows/Num1208.java

diff --git a/src/main/java/com/cool/ling_cha_mount/sliding_windows/Num1208.java b/src/main/java/com/cool/ling_cha_mount/sliding_windows/Num1208.java
new file mode 100644
index 0000000..dee5416
--- /dev/null
+++ b/src/main/java/com/cool/ling_cha_mount/sliding_windows/Num1208.java
@@ -0,0 +1,35 @@
+package com.cool.ling_cha_mount.sliding_windows;
+
+import org.junit.Test;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @Author: Cool
+ * @Date: 2024/10/18/12:28
+ * @Description: 1208. 尽可能使字符串相等
+ * Hard 2
+ * Score 1497
+ */
+public class Num1208 {
+    public int equalSubstring(String s, String t, int maxCost) {
+        int curCost = maxCost;
+        int left = 0;
+        int res = 0;
+        char[] sChar = s.toCharArray();
+        char[] tChar = t.toCharArray();
+        for (int i = 0; i < sChar.length; i++) {
+            curCost -= Math.abs(sChar[i] - tChar[i]);
+            while (curCost < 0) {
+                curCost+=Math.abs(sChar[left]-tChar[left++]);
+            }
+            res = Math.max(res, i - left + 1);
+        }
+        return res;
+    }
+
+    @Test
+    public void test() {
+        equalSubstring("krrgw", "zjxss", 19);
+    }
+}