File: root - text - article - 2020 - 01 - determine-if-linked-list-is-palindrome.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 385 Views, 26339 Search Bots | 102 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 385 Views, 26339 Search Bots | 102 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by Microsoft:
You are given a doubly linked list. Determine if it is a palindrome.
Can you do this for a singly linked list?
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 385 Views, 26339 Search Bots | 102 Words You are given a doubly linked list. Determine if it is a palindrome.
Can you do this for a singly linked list?
class Node(object):
def __init__(self, val):
self.val = val
self.next = None
self.prev = None
def is_palindrome(node):
# Fill this in.
node = Node('a')
node.next = Node('b')
node.next.prev = node
node.next.next = Node('b')
node.next.next.prev = node.next
node.next.next.next = Node('a')
node.next.next.next.prev = node.next.next
print is_palindrome(node)
# True
Related Articles
- CVE-2015-8874 - cPanel EasyApache Vulnerabilities
- Find Pythagorean Triplets
- Algorithm Interview: Make the Largest Number
- Making a Height Balanced Binary Search Tree
- Plus One
- Daily Interview Problem: Decode String
- Invert a Binary Tree
- [Daily Problem] Move Zeros
- Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
- Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
©2006~2024 SteakOverCooked - 0.00988 Seconds(s) - 5463.669 KB/s - 55 Online Memory: 519.67 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !