题解 | #回文昵称# 字符串模拟题

回文昵称

https://www.nowcoder.com/practice/5ac63bfdf73c473d9dee7e3294551563

知识点

字符串

思路

按照要求模拟即可,这里用python很方便。

AC Code(python)

#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param s string字符串 
# @return bool布尔型
#
class Solution:
    def isPalindromeNickname(self , s: str) -> bool:
        lst = [x for x in s.lower() if x.isalpha() or x.isdigit()]
        return lst == lst[::-1]

全部评论

相关推荐

不会hc都被抢完了吧
投递深圳市新凯来技术等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务