To the Top
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 | 173 Views, 21855 Search Bots | 102 Words

Subscribe to Feed Burner | 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?


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
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 173 Views, 21855 Search Bots | 102 Words Subscribe to Feed Burner

Related Articles

  1. Generate All IP Addresses
  2. Daily Interview Problem: Deepest Node in a Binary Tree
  3. Daily Interview Problem:Create a balanced binary search tree
  4. Daily Interview Problem: Merge List Of Number Into Ranges
  5. First and Last Indices of an Element in a Sorted Array
  6. Daily Interview Problem: Reverse Words in a String
  7. CVE-2015-8874 - cPanel EasyApache Vulnerabilities
  8. Daily Interview Problem: Product of Array Except Self
  9. Daily Interview Problem: Validate Binary Search Tree
  10. Detect Linked List Cycle

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />