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

Related Articles

  1. Spectrum Master
  2. Daily Interview Problem: Contiguous Subarray with Maximum Sum
  3. Progess made
  4. Daily Interview Question: Create a Simple Calculator
  5. [Daily Problem] Move Zeros
  6. Design Tic-Tac-Toe
  7. Plus One
  8. Daily Interview Puzzle: Minimum Size Subarray Sum
  9. Daily Interview Problem: Queue Using Two Stacks
  10. Two Tricks of Delphi

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