删除测试文件
parent
f377867c5a
commit
cf706724b1
@ -1,64 +0,0 @@
|
||||
public class TzTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String a = "abaa";
|
||||
|
||||
System.out.println(split(a));
|
||||
|
||||
// System.out.println(isR("aabbaa".toCharArray(), 0, 6));
|
||||
// System.out.println(isR("a1bbcc".toCharArray(), 0, 6));
|
||||
// System.out.println(isR("acbca".toCharArray(), 0, 5));
|
||||
// System.out.println(isR("acbc1".toCharArray(), 0, 5));
|
||||
}
|
||||
|
||||
|
||||
public static int split(String str) {
|
||||
if (str == null || str.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
final char[] chars = str.toCharArray();
|
||||
int len = chars.length;
|
||||
int[] dp = new int[len + 1];
|
||||
dp[len] = 0;
|
||||
dp[len - 1] = 1;
|
||||
boolean[][] p = record(chars);
|
||||
for (int i = len - 2; i >= 0; i--) {
|
||||
dp[i] = chars.length - i;
|
||||
for (int j = i; j < len; j++) { // i..j
|
||||
if (p[i][j]) {
|
||||
dp[i] = Math.min(dp[i], dp[j + 1] + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return dp[0];
|
||||
}
|
||||
|
||||
public static boolean[][] record(char[] str) {
|
||||
int len = str.length;
|
||||
boolean[][] record = new boolean[len][len];
|
||||
record[len - 1][len - 1] = true;
|
||||
for (int i = 0; i < len - 1; i++) {
|
||||
record[i][i] = true;
|
||||
record[i][i + 1] = str[i] == str[i + 1];
|
||||
}
|
||||
for (int row = len - 3; row >= 0; row--) {
|
||||
for (int col = row + 2; col < len; col++) {
|
||||
record[row][col] = str[row] == str[col] && record[row + 1][col - 1];
|
||||
}
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
// public static boolean isR(char[] chars, int start, int end) {
|
||||
// for (int i = start; i < end / 2; i++) {
|
||||
// System.out.println(chars[i] + "---" + chars[end - i - 1]);
|
||||
// if (chars[i] != chars[end - i - 1]) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.ibeetl.jlw;
|
||||
|
||||
import com.ibeetl.jlw.entity.Classes;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TzTest {
|
||||
public static void main(String[] args) {
|
||||
List<Classes> c = new ArrayList<>();
|
||||
|
||||
List<String> collect = c.stream().map(Classes::getName).collect(Collectors.toList());
|
||||
|
||||
|
||||
System.out.println(collect);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue