(String s)
| 1 | public class Solution { |
| 2 | |
| 3 | public List<List<String>> partition(String s) { |
| 4 | List<List<String>> res = new ArrayList<List<String>>(); |
| 5 | if (s.equals("")) { |
| 6 | res.add(new ArrayList<String>()); |
| 7 | return res; |
| 8 | } |
| 9 | for (int i = 0; i < s.length(); i++) { |
| 10 | if (isPalindrome(s, i + 1)) { |
| 11 | for (List<String> list : partition(s.substring(i + 1))) { |
| 12 | list.add(0, s.substring(0, i + 1)); |
| 13 | res.add(list); |
| 14 | } |
| 15 | } |
| 16 | } |
| 17 | return res; |
| 18 | } |
| 19 | |
| 20 | public boolean isPalindrome(String s, int n) { |
| 21 | for (int i = 0; i < n / 2; i++) { |
nothing calls this directly
no test coverage detected