momottyy的专栏

自律 自由

【python3】从leetcode 114 & 589 讲解关于树的先序遍历题

先序遍历 preorder 遍历顺序:根结点-左子树-右子树,如下图蓝色为先序(4个算法的遍历结果都为12345) 1 递归写法 def pretraversal(root): preval.append(root.va...

2019-01-17 14:46:08

阅读数:3

评论数:0

【python3】从leetcode 102& 104 & 559 & 429 &111 讲解关于树的层序遍历题

树的结点定义 # Definition for a Node. class Node(object): def __init__(self, val, children): self.val = val self.children = children ...

2019-01-17 10:02:27

阅读数:7

评论数:0

【python3】leetcode 82. Remove Duplicates from Sorted List II (Medium)

82. Remove Duplicates from Sorted List II (Medium) Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct ...

2019-01-16 15:49:34

阅读数:4

评论数:0

【python3】leetcode 86. Partition List (Medium)

 86. Partition List (Medium) Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equa...

2019-01-15 16:38:43

阅读数:7

评论数:0

【python3】leetcode 143. Reorder List(Medium)

143. Reorder List(Medium) Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not modify the values in t...

2019-01-15 10:30:52

阅读数:7

评论数:0

【python3】leetcode 500. Keyboard Row (easy)

500. Keyboard Row (easy) Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard...

2019-01-15 08:51:16

阅读数:14

评论数:0

【python3】leetcode 61. Rotate List (Medium)

61. Rotate List (Medium)  Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: Input: 1-&g...

2019-01-14 20:12:03

阅读数:8

评论数:0

【python3】leetcode 442. Find All Duplicates in an Array (Medium)

442. Find All Duplicates in an Array (Medium)  Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others ...

2019-01-14 17:27:59

阅读数:9

评论数:0

【python3】leetcode 228. Summary Ranges (Medium)

228. Summary Ranges (Medium)  Given a sorted integer array without duplicates, return the summary of its ranges. Example 1: Input: [0,1,2,4,5,7...

2019-01-14 17:00:51

阅读数:10

评论数:0

【python3】leetcode 56. Merge Intervals (Medium)

 56. Merge Intervals (Medium) Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] O...

2019-01-14 16:04:13

阅读数:6

评论数:0

【python3】leetcode 238. Product of Array Except Self (Medium)

238. Product of Array Except Self (Medium)  Given an array nums of n integers where n > 1,  return an array output such that output[i] i...

2019-01-14 15:34:47

阅读数:8

评论数:0

【python3】leetcode 643. Maximum Average Subarray I(easy)

 643. Maximum Average Subarray I(easy) Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum...

2019-01-14 09:02:15

阅读数:11

评论数:0

【python3】leetcode 26. Remove Duplicates from Sorted Array(easy)

26. Remove Duplicates from Sorted Array(easy)  Given a sorted array nums, remove the duplicates in-place such that each element appear only onceand...

2019-01-13 23:58:59

阅读数:8

评论数:0

【python3】leetcode 976. Largest Perimeter Triangle(easy)

 976. Largest Perimeter Triangle(easy) Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero area, formed ...

2019-01-13 23:24:47

阅读数:18

评论数:0

【python3】leetcode 717. 1-bit and 2-bit Characters (easy)

717. 1-bit and 2-bit Characters (easy)  We have two special characters. The first character can be represented by one bit 0. The second character c...

2019-01-13 22:37:25

阅读数:6

评论数:0

【python3】leetcode 766. Toeplitz Matrix(easy)

766. Toeplitz Matrix(easy) A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now given an M x N matrix, r...

2019-01-13 20:33:20

阅读数:11

评论数:0

【python3】leetcode 509. Fibonacci Number(easy)

509. Fibonacci Number(easy) The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is t...

2019-01-13 19:45:46

阅读数:18

评论数:0

【python3】leetcode 725. Split Linked List in Parts (Medium)

725. Split Linked List in Parts (Medium)  Given a (singly) linked list with head node root, write a function to split the linked list into kconsecu...

2019-01-11 15:19:40

阅读数:13

评论数:0

【python3】leetcode 8. String to Integer (atoi) (Meidum)

8. String to Integer (atoi) (Meidum)  Given two integers dividend and divisor, divide two integers without using multiplication, division and mod o...

2019-01-10 20:45:20

阅读数:12

评论数:0

【python3】leetcode 19. Remove Nth Node From End of List (Medium)

19. Remove Nth Node From End of List (Medium)  Given a linked list, remove the n-th node from the end of list and return its head. Example: Give...

2019-01-10 19:41:20

阅读数:13

评论数:0

提示
确定要删除当前文章?
取消 删除
关闭
关闭