Valid Palindrome II(dfs带while循环)

Given a non-empty strings, you may deleteat mostone character. Judge whether you can make it a palindrome.

Example 1:

Input:
 "aba"

Output:
 True

Example 2:

Input:
 "abca"

Output:
 True

Explanation:
 You could delete the character 'c'.

分析

带有while循环的递归,递归完全发生在while里面,参见dfs的for loop

注意python的ternary

iterative

Last updated

Was this helpful?