Check String Palindrom
Question
Given a string S and check if S is the palindrome
判断字符串是否是回文字符串。
Solution 1:
可以直接想到i 跟 n - i -1 进行比较。时间复杂度O(N)
Solution 2:
使用左右指针解题思路更清晰 而且便于扩展。
变型题:忽略空格特殊字符,然后比较
Last updated
Was this helpful?
Question
Given a string S and check if S is the palindrome
判断字符串是否是回文字符串。
Solution 1:
可以直接想到i 跟 n - i -1 进行比较。时间复杂度O(N)
Solution 2:
使用左右指针解题思路更清晰 而且便于扩展。
变型题:忽略空格特殊字符,然后比较
Last updated
Was this helpful?