get all Palindromes of a string
来源:互联网 发布:java微信 api好友列表 编辑:程序博客网 时间:2024/05/21 19:52
public static void main(String[] args) { AllPalindromes a = new AllPalindromes(); for (String str: a.getAllPalindrome("accbrrbccai2")){ System.out.println(str); }; System.out.println(); System.out.println(a.longestPalindrome("accbrrbccai2")); } List<String> res = null; public List<String> getAllPalindrome(String str) { res = new LinkedList<>(); if (str == null || str.length() <= 1) { return res; } for (int i = 0; i < str.length() * 2 - 1; i++) { int left = i/2; int right = (i)/2; if (i%2 == 1) { right++; } getPalindrome(str, left, right); } return res; } private void getPalindrome(String str, int left, int right){ while (left >= 0 && right < str.length() && str.charAt(left) == str.charAt(right)) { left--; right++; if (right - left > 2) { res.add(str.substring(left + 1, right)); } } }
0 0
- get all Palindromes of a string
- find all the permutation of a string
- print all permutation of a string(recursion)
- 1.Minimal Number of Palindromes on a String(dp)
- Write a method to compute all permutations of a string
- Generating all permutations of a given string(JAVA)
- get all rows count of all tables in a mysql database.
- All of a Sudden
- Get a list of all application currently installed on a phone
- Write a C program to print all permutations of a given string
- Q9.5 Write a method to compute all permutations of a string
- Write a program to print all permutations of a given string
- magento How to get all associated children product of a configurable product
- Get all URLs from a webpage
- A - Palindromes:
- Permutations of a String
- How To get the Real length of a string with chinese words
- [Beginning Visual C++ 2008]to get rid of space in a string
- 【Web容器】Tomcat源码分析(2)-server.xml文件的加载与解析
- Socket实现远程调用实例
- JS中构造函数
- java夯实基础系列:面对对象原则
- java设计模式_外观模式
- get all Palindromes of a string
- continue,break控制流程
- 后缀数组 模板
- 【Web容器】Tomcat源码分析(3)-生命周期管理
- 使用枚举代替常量,简化工作!
- Docker 构建 Java Web 开发环境——使用Dockerfile(二)
- 数据结构笔记--总结各种排序算法及其应用
- 【Web容器】Tomcat源码分析(4)-启动与停止服务
- HDU 1536 SG函数模板