Skip to content

Commit 670ad05

Browse files
add 2697
1 parent aaf9b6c commit 670ad05

File tree

2 files changed

+20
-0
lines changed
  • paginated_contents/algorithms/3rd_thousand
  • src/main/java/com/fishercoder/solutions/thirdthousand

2 files changed

+20
-0
lines changed

paginated_contents/algorithms/3rd_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
| 2716 | [Minimize String Length](https://leetcode.com/problems/minimize-string-length/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2716.java) | [:tv:](https://youtu.be/aMJ3T0K8LjI) | Easy |
99
| 2710 | [Remove Trailing Zeros From a String](https://leetcode.com/problems/remove-trailing-zeros-from-a-string/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2710.java) | | Easy |
1010
| 2706 | [Buy Two Chocolates](https://leetcode.com/problems/buy-two-chocolates/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2706.java) | | Easy |
11+
| 2697 | [Lexicographically Smallest Palindrome](https://leetcode.com/problems/lexicographically-smallest-palindrome/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2697.java) | | Easy |
1112
| 2696 | [Minimum String Length After Removing Substrings](https://leetcode.com/problems/minimum-string-length-after-removing-substrings/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2696.java) | | Easy |
1213
| 2670 | [Find the Distinct Difference Array](https://leetcode.com/problems/find-the-distinct-difference-array/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2670.java) | | Easy |
1314
| 2596 | [Check Knight Tour Configuration](https://leetcode.com/problems/check-knight-tour-configuration/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2596.java) | [:tv:](https://youtu.be/OBht8NT_09c) | Medium |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.fishercoder.solutions.thirdthousand;
2+
3+
public class _2697 {
4+
public static class Solution1 {
5+
public String makeSmallestPalindrome(String s) {
6+
char[] charArray = s.toCharArray();
7+
for (int i = 0, j = s.length() - 1; i < j; i++, j--) {
8+
if (charArray[i] != charArray[j]) {
9+
if (charArray[i] < charArray[j]) {
10+
charArray[j] = charArray[i];
11+
} else {
12+
charArray[i] = charArray[j];
13+
}
14+
}
15+
}
16+
return new String(charArray);
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)