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 | 421 Views, 26827 Search Bots | 102 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 421 Views, 26827 Search Bots | 102 Words
| 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?
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 421 Views, 26827 Search Bots | 102 Words 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
Related Articles
- [Daily Problem] Validate Balanced Parentheses
- Algorithm Interview: No Adjacent Repeating Characters
- Daily Interview Problem: Maximum Profit From Stocks
- Floor and Ceiling of a Binary Search Tree
- Two-Sum
- [Daily Problem] Longest Palindromic Substring
- Daily Interview Problem: Contiguous Subarray with Maximum Sum
- Algorithm Interview: Make the Largest Number
- Design Tic-Tac-Toe
- Algorithm Interview: Determine If Linked List is Palindrome
©2006~2024 SteakOverCooked - 0.01181 Seconds(s) - 1605.203 KB/s - 66 Online Memory: 494.13 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !