2022-12-02 LC题解-左旋转字符串 反转区间为前n的子串 反转区间为n到末尾的子串 反转整个字符串 12345678910111213141516171819202122232425262728293031323334class Solution { public String reverseLeftWords(String s, int n) { char[] sc = s.toCharArray(); // 前 sc.length - n 翻转 int l = 0; int r = n - 1; while(l < r) { char t = sc[l]; sc[l++] = sc[r]; sc[r--] = t; } // n 到 结尾翻转 l = n; r = sc.length - 1; while(l < r) { char t = sc[l]; sc[l++] = sc[r]; sc[r--] = t; } // 全部翻转 l = 0; r = sc.length - 1; while(l < r) { char t = sc[l]; sc[l++] = sc[r]; sc[r--] = t; } return new String(sc); }} Nuevo SpringBoot与Mybatis下字段脱敏、加密解密非侵入性实现方式 Viejo JDK的Arrays.sort源码阅读