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 | 447 Views, 27004 Search Bots | 102 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 447 Views, 27004 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 | 447 Views, 27004 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
- 56 Bytes
- Daily Interview Puzzle: Ways to Traverse a Grid
- Reverse a Directed Graph
- Daily Interview Question: Find Cycles in a Graph
- Daily Interview Problem: Trapping Rainwater
- Daily Interview Problem: Queue Using Two Stacks
- Floor and Ceiling of a Binary Search Tree
- Daily Interview Problem: Full Binary Tree
- Algorithm Interview: Longest Consecutive Sequence
- Daily Interview Question: Edit Distance
©2006~2024 SteakOverCooked - 0.00846 Seconds(s) - 6366.245 KB/s - 30 Online Memory: 529.19 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 !