Skip to content

Commit 1649f1a

Browse files
add 1750
1 parent 5cbd633 commit 1649f1a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1750|[Minimum Length of String After Deleting Similar Ends](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1750.java) ||Medium|Two Pointers|
1112
|1749|[Maximum Absolute Sum of Any Subarray](https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1749.java) ||Medium|Greedy|
1213
|1748|[Sum of Unique Elements](https://leetcode.com/problems/sum-of-unique-elements/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1748.java) ||Easy|Array, HashTable|
1314
|1745|[Palindrome Partitioning IV](https://leetcode.com/problems/palindrome-partitioning-iv/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1745.java) ||Hard|String, DP|
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _1750 {
4+
public static class Solution1 {
5+
public int minimumLength(String s) {
6+
int i = 0;
7+
int j = s.length() - 1;
8+
if (s.charAt(i) == s.charAt(j)) {
9+
while (i < j && s.charAt(i) == s.charAt(j)) {
10+
char c = s.charAt(i);
11+
i++;
12+
while (c == s.charAt(i) && i < j) {
13+
i++;
14+
}
15+
j--;
16+
while (c == s.charAt(j) && i < j) {
17+
j--;
18+
}
19+
}
20+
}
21+
return i <= j ? s.substring(i, j).length() + 1 : 0;
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)