/* * @lc app=leetcode.cn id=1960 lang=java * * [1960] 两个回文子字符串长度的最大乘积 */ // @lc code=start import java.util.ArrayList; import java.util.List; class Solution { public long maxProduct(String s) { List stringAsciiList = conv2ascii(s); List stringAndList = new ArrayList<>(); int listLength = stringAsciiList.size(); for (int i = 0; i < listLength; i++) { int a = stringAsciiList.get(i) + stringAsciiList.get(listLength - 1 - i); int b = stringAsciiList.get(i) * 2; stringAndList.add(a == b ? 1 : 0); } System.out.println(stringAndList); return 0; } /** * 获取字符串的ascii码字符串 * * @param s * @return */ private List conv2ascii(String s) { List stringAsciiList = new ArrayList<>(); for (char item : s.toCharArray()) { stringAsciiList.add((int) item); }; return stringAsciiList; } public static void main(String[] args) { Solution solution = new Solution(); solution.maxProduct("ababbb"); } } // @lc code=end