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, 22182 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, 22182 Search Bots | 102 Words Subscribe to Feed Burner

Related Articles

  1. [Daily Problem] Remove k-th Last Element From Linked List
  2. Daily Interview Problem: Maximum Profit From Stocks
  3. Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
  4. Find Missing Numbers in an Array
  5. Daily Interview Problem: Count Number of Unival Subtrees
  6. Algorithm Interview Question: Symmetric k-ary Tree
  7. Reverse a Linked List
  8. Algorithm Interview Question: Find the Single Element in an Array of Duplicates
  9. Algorithm Interview: Convert Roman Numerals to Decimal
  10. Daily Interview Problem: Minimum Removals for Valid Parenthesis

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />