- 博客(8)
- 收藏
- 关注
原创 Leetcode160 Intersection of 2 Linked List (Solved myself within 20 miniutes!!)
Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: # Definition for singly-linked list. # class ListNode(object)...
2019-09-28 05:27:22
130
原创 LC234 Panlindrome Linked List
class Solution(object): def isPalindrome(self, head): “”" :type head: ListNode :rtype: bool “”" # second method if not head or not head.next: return True # 1. Get the midpoint (slow)...
2019-09-27 18:46:59
189
原创 Leetcode 141: Linked List Cycle
Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail con...
2019-09-27 16:12:25
140
原创 Leetcode 20 Valid Parentheses Use Stack
Given a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of bra...
2019-09-27 16:10:09
105
原创 Leetcode155 Min Stack use Python
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the ...
2019-09-26 19:02:16
118
原创 LeetCode198 House Robber, Recursion and DP
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house...
2019-09-26 18:13:46
156
1
原创 LC437 Path Sum III
Definition for a binary tree node. class TreeNode(object): def init(self, x): self.val = x self.left = None self.right = None class Solution(object): def pathSum(self, root, sum): “”" :type root: Tree...
2019-09-26 17:03:17
105
原创 LC101 Binary Tree check Symmetry
LC101 Binary Tree Symmetry 几种方法: 1)recursively compare two mirror trees, check if corresponding element is equal. 2) Using Stacks,(use list to append and pop, not memory efficient; use collections.de...
2019-09-26 04:28:50
124
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人