0%

本次题解包括

  • 89. Gray Code
  • 136 Single Number
  • 137 Single Number II
  • 190 Reverse Bits
  • 191 Number of 1 Bits
  • 201 Bitwise AND of Numbers Range
  • 260 Single Number III
  • 268 Missing Number
阅读全文 »

本次题解包括

  • 121 Best Time to Buy and Sell Stock
  • 122 Best Time to Buy and Sell Stock II
  • 123 Best Time to Buy and Sell Stock III
  • 188 Best Time to Buy and Sell Stock IV
  • 714. Best Time to Buy and Sell Stock with Transaction Fee
阅读全文 »

本次题解为 leetcode tree 的整理,包括

  • 依照leetcode定义 自己写的createTree方法,便于测试中序遍历的下标和
  • 94 Binary Tree Inorder Traversal
  • 95 Unique Binary Search Trees II
  • 96 Unique Binary Search Trees
  • 98 Validate Binary Search Tree
  • 99 Recover Binary Search Tree
  • 100 Same Tree
  • 101 Symmetric Tree
  • 102 Binary Tree Level Order Traversal
  • 103 Binary Tree Zigzag Level Order Traversal
  • 104 Maximum Depth of Binary Tree
  • 105 Construct Binary Tree from Preorder and Inorder Traversal
  • 106 Construct Binary Tree from Inorder and Postorder Traversal
  • 107 Binary Tree Level Order Traversal II
  • 108 Convert Sorted Array to Binary Search Tree
  • 109 Convert Sorted List to Binary Search Tree
  • 110 Balanced Binary Tree
  • 111 Minimum Depth of Binary Tree
  • 112 Path Sum
  • 113 Path Sum II
  • 114 Flatten Binary Tree to Linked List
  • 116 Populating Next Right Pointers in Each Node
  • 117 Populating Next Right Pointers in Each Node II
  • 124 Binary Tree Maximum Path Sum
  • 129 Sum Root to Leaf Numbers
  • 144 Binary Tree Preorder Traversal
  • 145 Binary Tree Postorder Traversal
  • 173 Binary Search Tree Iterator
  • 199 Binary Tree Right Side View
  • 222 Count Complete Tree Nodes
  • 226 Invert Binary Tree
  • 230 Kth Smallest Element in a BST
  • 235 Lowest Common Ancestor of a Binary Search Tree
  • 236 Lowest Common Ancestor of a Binary Tree
  • 257 Binary Tree Paths
  • 297 Serialize and Deserialize Binary Tree
  • 449. Serialize and Deserialize BST
阅读全文 »

leetcode dfs 归纳整理 包括:

  • 17. Letter Combinations of a Phone Number
  • 22. Generate Parentheses
  • 39 Combination Sum
  • 40 Combination Sum II
  • 51 N-Queens
  • 52 N-Queens II
  • 77 Combinations
  • 78 Subsets
  • 79 Word Search
  • 90 Subsets II
  • 200 Number of Islands
  • 216 Combination Sum III
  • 241 Different Ways to Add Parentheses
  • 282 Expression Add Operators
  • 797. All Paths From Source to Target
阅读全文 »

本次题解包括:

  • 4 Median of Two Sorted Arrays
  • 33 Search in Rotated Sorted Array
  • 34 Search for a Range
  • 35 Search Insert Position
  • 69 Sqrt(x)
  • 74 Search a 2D Matrix
  • 81 Search in Rotated Sorted Array II
  • 153 Find Minimum in Rotated Sorted Array
  • 154 Find Minimum in Rotated Sorted Array II
  • 240 Search a 2D Matrix II
阅读全文 »

Cool Idea

kindle 是我最喜欢的设备之一,入手一年以来,在上面我已经阅读了将近70本书,而又喜欢原版的系统(因为可以接受各种推送。如浏览网页直接 推送到kindle上等),刷了多看又卸载掉。kindle的原书笔记很丑。而且按照标记笔记时间进行排列。要是我同时读的有多本,标记的也有多本呢?那笔记会十分混乱。所以决定写下代码,帮助我进行分类。

之前在CSDN写过C++的,版本称为1.0吧,不过有bug就是中文字符什么的。

现在更新pyhon2.0版。

阅读全文 »

leetcode Text Justification

Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.

You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when necessary so that each line has exactly_L_ characters.

Extra spaces between words should be distributed as evenly as possible. If the number of spaces on a line do not divide evenly between words, the empty slots on the left will be assigned more spaces than the slots on the right.

For the last line of text, it should be left justified and no extra space is inserted between words.

For example, words: ["This", "is", "an", "example", "of", "text", "justification."] L: 16.

Return the formatted lines as:

[ "This is an", "example of text", "justification. "]

Note: Each word is guaranteed not to exceed L in length.

阅读全文 »