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

Related Articles

  1. Batch Programming in XP
  2. Daily Interview Problem: Min Stack
  3. Find Pythagorean Triplets
  4. Sorting a list with 3 unique numbers
  5. Daily Interview Problem: Circle of Chained Words
  6. Daily Interview Problem: Count Number of Unival Subtrees
  7. Daily Interview Puzzle: Minimum Size Subarray Sum
  8. Daily Interview Problem: Sort Colors
  9. Daily Interview Puzzle: Intersection of Linked Lists
  10. Palindrome Integers

Comments (0)

    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="index, follow">