1.下一个回文数

2.跑步机的使用次数


3.数组转置


4.压缩字符串最短结果输出

import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
Solution solution = new Solution();
String answer =solution.compressString(str);
System.out.println(answer);
}
}
class Solution{
public String compressString(String S) {
StringBuffer sb = new StringBuffer();
int i = 0;
while (i < S.length()) {
int j = i + 1;
while (j < S.length() && S.charAt(i) == S.charAt(j)) {
j++;
}
sb.append(String.valueOf(j - i)+String.valueOf(S.charAt(i)) );
i = j;
}
return sb.toString();
//sb.toString().length() < S.length() ? sb.toString() : S;
}
}
