题目

LeetCode验证回文串(Python)

解题思路

判断回文不难,其实就是要去忽视无效字符。普通的做法应该是利用双指针,然后判断当前字符如果不是字母或数字就忽略,但比较啰嗦。所以这里利用了一些python的内建函数:

str.isalnum():
LeetCode验证回文串(Python)
filter():
LeetCode验证回文串(Python)
str.lower():
LeetCode验证回文串(Python)
代码如下:
LeetCode验证回文串(Python)

执行结果为:
LeetCode验证回文串(Python)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2022-01-24
  • 2021-09-18
  • 2021-06-01
  • 2021-08-25
猜你喜欢
  • 2021-08-27
  • 2022-12-23
  • 2021-11-05
  • 2021-07-13
  • 2021-05-02
  • 2022-01-10
相关资源
相似解决方案