LC.P2697[字典序最小回文串] 方法一:贪心+双指针123456789class Solution { public String makeSmallestPalindrome(String s) { char[] cs = s.toCharArray(); for (int i = 0, j = cs.length - 1; i < j; ++i, --j) { cs[i] = cs[j] = (char) Math.min(cs[i], cs[j]); } return new String(cs); }} 时间复杂度:$O(n)$ 空间复杂度:$O(n)$