摘要: * 题:[回文链表](https://leetcode-cn.com/problems/palindrome-linked-list/)----* 解:## 1. 使用栈 先遍历链表将数据压入栈中,然后再次遍历链表与出栈的数据做对比,如果有不相同的说明不是回文链表。时间开销O(n) 空间开销O(n)* Python3 ```python # Definition for singly-... 阅读全文
posted @ 2020-06-17 20:12 暮晨 阅读(139) 评论(0) 推荐(0) 编辑
摘要: * 题:[验证回文串](https://leetcode-cn.com/problems/valid-palindrome/)----* 解 思路很简单,两个指针,一个从前向后遍历,一个从后向前遍历,直到两个指针相遇。如果中间出现两个值不相同的情况,说明不是回文串。* Python ``` class Solution: def isPalindrome(self,... 阅读全文
posted @ 2020-06-17 14:53 暮晨 阅读(221) 评论(0) 推荐(0) 编辑

Aaron Swartz was and will always be a hero