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 | 487 Views, 29237 Search Bots | 102 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 487 Views, 29237 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 | 487 Views, 29237 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
- Daily Interview Problem: Maximum Profit From Stocks
- Kaprekar
- Non-decreasing Array with Single Modification
- Daily Interview Problem: Running Median
- Most Frequent Subtree Sum
- Daily Interview Problem: Arithmetic Binary Tree
- Find Missing Numbers in an Array
- Daily Interview Problem:Create a balanced binary search tree
- CVE-2015-8874 - cPanel EasyApache Vulnerabilities
- Windows Scripting
©2006~2024 SteakOverCooked - 0.00951 Seconds(s) - 2099.912 KB/s - 10 Online Memory: 495.13 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="index, 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 !