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

Related Articles

  1. Daily Interview Problem: Distribute Bonuses
  2. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  3. Daily Interview Problem: Full Binary Tree
  4. Algorithm Interview: Shifted String
  5. How to Play WAV music under DOS?
  6. Algorithm Interview: Convert Roman Numerals to Decimal
  7. Palindrome Integers
  8. [Daily Problem] Angles of a Clock
  9. Daily Interview Problem: Merge Overlapping Intervals
  10. Detect Linked List Cycle

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" />