Skip to content

Commit 010773a

Browse files
authored
Update PalindromePartitioning.java
1 parent 50e6081 commit 010773a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Backtracking/PalindromePartitioning.java

+6
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ public void helper(String s, int index, List<String> l, List<List<String>> res){
2020
//recursion to see if it is possible to break down the remaining string into
2121
//palindromic substrings or not.
2222
for(int i = index ; i < s.length() ; i++){
23+
//check if the current substring is a palindrome or not
2324
if(isPalin(s, index, i)){
25+
26+
//make a partition
2427
l.add(s.substring(index, i+1));
28+
2529
helper(s, i+1, l, res);
30+
31+
//backtarck - undo the partition
2632
l.remove(l.size()-1);
2733
}
2834
}

0 commit comments

Comments
 (0)