August 22, 2015
51 N-Queens
https://github.com/jianminchen/AlgorithmsPractice/blob/master/EightPuzzelQueen.cs
https://github.com/jianminchen/Leetcode_C-/blob/master/51NQueenProblems.cs
http://juliachencoding.blogspot.ca/2015/06/algorithm-eight-puzzle-queen.html
52 N-Queens II
53 Maximum Subarray
54 Spiral Matrix
55 Jump Game
56 Merge Intervals
57 Insert Intervals
C# implementation:
https://github.com/jianminchen/Leetcode_C-/blob/master/57InsertIntervals.cs
58 Length of Last Word
https://github.com/jianminchen/Leetcode_C-/blob/master/58LengthOfLastWord.cs
59 Spiral Matrix II
60 Permutataion Sequence
From January 2015, she started to practice leetcode questions; she trains herself to stay focus, develops "muscle" memory when she practices those questions one by one. 2015年初, Julia开始参与做Leetcode, 开通自己第一个博客. 刷Leet code的题目, 她看了很多的代码, 每个人那学一点, 也开通Github, 发表自己的代码, 尝试写自己的一些体会. She learns from her favorite sports – tennis, 10,000 serves practice builds up good memory for a great serve. Just keep going. Hard work beats talent when talent fails to work hard.
Saturday, August 22, 2015
Leetcode questions 161 - 170
August 22, 2015
161 One Edit distance
162 Find Peak Element
http://juliachencoding.blogspot.ca/2015/06/leetcode-question-find-peak-element.html
need to write first C# implementation for this problem.
163 Missing Ranges
164 Maximum Gap
165 Compare Version Numbers
166 Fraction to Recurring Decimal
167 Two Sum II - Input array is sorted
168 Excel Sheet Column Title
169 Majority Element
170 Two Sum III - Data Structure Design
161 One Edit distance
162 Find Peak Element
http://juliachencoding.blogspot.ca/2015/06/leetcode-question-find-peak-element.html
need to write first C# implementation for this problem.
163 Missing Ranges
164 Maximum Gap
165 Compare Version Numbers
166 Fraction to Recurring Decimal
167 Two Sum II - Input array is sorted
168 Excel Sheet Column Title
169 Majority Element
170 Two Sum III - Data Structure Design
Leetcode question 151 - 160
August 22, 2015
151 Reverse words in a string
152 Maximum Product Subarray
http://juliachencoding.blogspot.ca/2015/08/leetcode-maximum-product-subarray.html
153 Find Minimum in Rotated Sorted Array
154 Find Minimum in Rotated Sorted Array II
155 Min Stack
156 Binary Tree Upside Down
157 Read N Characters Given Read 4
158 Read N Characters Given Read 4 II - Call multiple times
159 Longest Substring with At Most Two Distinct Characters
160 Intersection of Two Linked List
151 Reverse words in a string
152 Maximum Product Subarray
http://juliachencoding.blogspot.ca/2015/08/leetcode-maximum-product-subarray.html
153 Find Minimum in Rotated Sorted Array
154 Find Minimum in Rotated Sorted Array II
155 Min Stack
156 Binary Tree Upside Down
157 Read N Characters Given Read 4
158 Read N Characters Given Read 4 II - Call multiple times
159 Longest Substring with At Most Two Distinct Characters
160 Intersection of Two Linked List
Leetcode question 140 - 150
August 22, 2015
140 Word Break II
141 Linked List Cycle
142 Lined List Cycle II
143 Reorder List
144 Binary Tree Preorder Traversal
http://juliachencoding.blogspot.ca/2015/06/leetcode-binary-tree-preorder-traversal.html
145 Binary Tree Postorder Traversal
http://juliachencoding.blogspot.ca/2015/06/leetcode-post-order-binary-tree.html
146 LRU Cache
147 Insertion Sort List
148 Sort List
149 Max Points on a Line
150 Evaluate Reverse Polish Notation
140 Word Break II
141 Linked List Cycle
142 Lined List Cycle II
143 Reorder List
144 Binary Tree Preorder Traversal
http://juliachencoding.blogspot.ca/2015/06/leetcode-binary-tree-preorder-traversal.html
145 Binary Tree Postorder Traversal
http://juliachencoding.blogspot.ca/2015/06/leetcode-post-order-binary-tree.html
146 LRU Cache
147 Insertion Sort List
148 Sort List
149 Max Points on a Line
150 Evaluate Reverse Polish Notation
Leetcode question 130 - 140
August 22, 2015
130 Surrounded Regions
131 Palindrome Partitioning
132 Palindrome Partitioning II
133 Clone Graph
134 Gas Station
135 Candy
http://juliachencoding.blogspot.ca/2015/06/leetcode-candy_9.html
136 Single Number
137 Single Number II
138 Copy List with Random Pointer
139 Word Break
140 Word Break II
130 Surrounded Regions
131 Palindrome Partitioning
132 Palindrome Partitioning II
133 Clone Graph
134 Gas Station
135 Candy
http://juliachencoding.blogspot.ca/2015/06/leetcode-candy_9.html
136 Single Number
137 Single Number II
138 Copy List with Random Pointer
139 Word Break
140 Word Break II
Leetcode questions 120 - 130
August 22, 2015
120 Triangle
write a blog, need to write C# code.
http://juliachencoding.blogspot.ca/2015/06/leetcode-triangle.html
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 II I
124 Binary Tree Maximum Path Sum
http://juliachencoding.blogspot.ca/2015/07/leetcode-maximum-binary-tree-path-sum.html
Tree Maximum Path Sum
http://juliachencoding.blogspot.ca/2015/07/itint5-tree-maximum-path-sum.html
Tree maximum path sum:
125 Valid Palindrome
126 Word Ladder II
127 Word Ladder
http://juliachencoding.blogspot.ca/2015/06/leetcode-word-ladder.html
128 Longest Consecutive Sequence
129 Sum Root to Leaf Numbers
130 Surrounded Regions
--
Question No: 124
C# implementation:
https://github.com/jianminchen/Leetcode_C-/blob/master/124BinaryTreeMaximumPathSum.cs
Maybe, similar problem: ITINT5 Tree Maximum Path Sum
http://juliachencoding.blogspot.ca/2015/07/itint5-tree-maximum-path-sum.html
120 Triangle
write a blog, need to write C# code.
http://juliachencoding.blogspot.ca/2015/06/leetcode-triangle.html
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 II I
124 Binary Tree Maximum Path Sum
http://juliachencoding.blogspot.ca/2015/07/leetcode-maximum-binary-tree-path-sum.html
Tree Maximum Path Sum
http://juliachencoding.blogspot.ca/2015/07/itint5-tree-maximum-path-sum.html
Tree maximum path sum:
125 Valid Palindrome
126 Word Ladder II
127 Word Ladder
http://juliachencoding.blogspot.ca/2015/06/leetcode-word-ladder.html
128 Longest Consecutive Sequence
129 Sum Root to Leaf Numbers
130 Surrounded Regions
--
Question No: 124
C# implementation:
https://github.com/jianminchen/Leetcode_C-/blob/master/124BinaryTreeMaximumPathSum.cs
Maybe, similar problem: ITINT5 Tree Maximum Path Sum
http://juliachencoding.blogspot.ca/2015/07/itint5-tree-maximum-path-sum.html
Leetcode question 111 - 120
August 22, 2015
111 Minimum Depth of Binary Tree
112 Path Sum
113 Path Sum II
114 Flatten Binary Tree to Linked List
115 Distinct Subsequences
116 Populating Next Right Pointers in Each Node
117 Populating Next Right Pointers in Each Node II
118 Pascal's Triangle
119 Pascal's Triangle II
120 Triangle
111 Minimum Depth of Binary Tree
112 Path Sum
113 Path Sum II
114 Flatten Binary Tree to Linked List
115 Distinct Subsequences
116 Populating Next Right Pointers in Each Node
117 Populating Next Right Pointers in Each Node II
118 Pascal's Triangle
119 Pascal's Triangle II
120 Triangle
Leetcode questions 100 - 110
August 22, 2015
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 Constructu 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
--
101 Symmetric Tree (Sept. 8, 2015)
102 Binary Tree Level Order Traversal
6 different solutions:
103 Binary Tree Zigzag Level Order Traversal
104 Maximum Depth of Binary Tree
https://github.com/jianminchen/Leetcode_C-/blob/master/104MaximumDepthOfBinaryTree.cs
106 Constructu Binary Tree from Inorder and Postorder Traversal
https://github.com/jianminchen/Leetcode_C-/blob/master/106ConstructuBTreeFromInorderPostOrderTraversal.cs
106 Constructu Binary Tree from Inorder and Postorder Traversal
https://github.com/jianminchen/Leetcode_C-/blob/master/106ConstructuBTreeFromInorderPostOrderTraversal.cs
second
implementation using C#:
https://github.com/jianminchen/Leetcode_C-/blob/master/106ConstructBTreeFromInOrderPostOrderTraversal_B.cs
Leetcode 106: January 2, 2015
Further reading: (1 hour)
Serialize and Deserialize a Binary Tree
http://www.geeksforgeeks.org/serialize-deserialize-binary-tree/
http://www.cs.usfca.edu/~brooks/S04classes/cs245/lectures/lecture11.pdf
https://github.com/jianminchen/Leetcode_C-/blob/master/106ConstructBTreeFromInOrderPostOrderTraversal_B.cs
Leetcode 106: January 2, 2015
Further reading: (1 hour)
Serialize and Deserialize a Binary Tree
http://www.geeksforgeeks.org/serialize-deserialize-binary-tree/
http://www.cs.usfca.edu/~brooks/S04classes/cs245/lectures/lecture11.pdf
108 Convert sorted array to binary
search tree (No. 108)
109 Convert sorted list to binary search tree
(No. 109)
8/25/2015
Read the following blogs:
C#, bottom up, time O(n), space O(log n)
solution - best solution:
C#, top down, time O(n^2), space O(long n)
solution - naive solution:
worked on code 2 times, first time, the
calculation is kind of messy, then, worked on Leetcode question 108, get the
idea to make it more simple; tips like len/2 only shows once, afterwards, use m
instead. Just need to improve coding, think to make it more abstract, simple.
https://github.com/jianminchen/Leetcode_C-/blob/master/109ConvertSortedListToBinarySearchTreeC.cs
9/21/2015
Review the best solution, and then, totally forgot the bottom up solution idea. So, update the code with more comment.
Need to review more about bottom up/ top down solution in tree problems. Get more experience on bottom-up solution, read some articles about it.
9/21/2015
Review the best solution, and then, totally forgot the bottom up solution idea. So, update the code with more comment.
Need to review more about bottom up/ top down solution in tree problems. Get more experience on bottom-up solution, read some articles about it.
Leetcode questions 90 - 100
August 22, 2015
90 subsets II
91 Decode ways
92 Reverse Linked List II
93 Restore IP Addresses
94 Binary Tree Inorder Traversal
95 Unique Binary Search Trees II
96 Unique Binary Search Trees
97 Interleaving String
98 Validate Binary Search Trees
99 Recover Binary Search Tree
100 Same Tree
-- Julia's practice:
94 Binary Tree Inorder Traversal
Julia's C# implementation:
https://github.com/jianminchen/leetcode-tree/blob/master/TreeDemo.cs
95 Unique Binary Search Trees II
https://github.com/jianminchen/Leetcode_C-/blob/master/95UniqueBinarySearchTreeII.cs
97 Interleaving String
the blog containing reading list:
http://juliachencoding.blogspot.ca/2015/06/leetcode-interleave-string.html
Need to write first C# implementation.
99 Recover Binary Search Tree
blogs:
http://www.lifeincode.net/programming/leetcode-recover-binary-search-tree-java/
http://www.cnblogs.com/AnnieKim/archive/2013/06/15/MorrisTraversal.html
C# implementations:
https://github.com/jianminchen/Leetcode_C-/blob/master/99RecoverBinarySearchTree.cs
https://github.com/jianminchen/Leetcode_C-/blob/master/99RecoverBinarySearchTreeB.cs
work on extracting small functions, and then, understand the algorithm better.
https://github.com/jianminchen/Leetcode_C-/blob/master/99RecoveryBinarySearchTree_C.cs
100 same tree
Two implementations,one recursive, one iterative solution.
https://github.com/jianminchen/Leetcode_C-/blob/master/100SameTree.cs
90 subsets II
91 Decode ways
92 Reverse Linked List II
93 Restore IP Addresses
94 Binary Tree Inorder Traversal
95 Unique Binary Search Trees II
96 Unique Binary Search Trees
97 Interleaving String
98 Validate Binary Search Trees
99 Recover Binary Search Tree
100 Same Tree
-- Julia's practice:
94 Binary Tree Inorder Traversal
Julia's C# implementation:
https://github.com/jianminchen/leetcode-tree/blob/master/TreeDemo.cs
95 Unique Binary Search Trees II
https://github.com/jianminchen/Leetcode_C-/blob/master/95UniqueBinarySearchTreeII.cs
97 Interleaving String
the blog containing reading list:
http://juliachencoding.blogspot.ca/2015/06/leetcode-interleave-string.html
Need to write first C# implementation.
99 Recover Binary Search Tree
blogs:
http://www.lifeincode.net/programming/leetcode-recover-binary-search-tree-java/
http://www.cnblogs.com/AnnieKim/archive/2013/06/15/MorrisTraversal.html
C# implementations:
https://github.com/jianminchen/Leetcode_C-/blob/master/99RecoverBinarySearchTree.cs
https://github.com/jianminchen/Leetcode_C-/blob/master/99RecoverBinarySearchTreeB.cs
work on extracting small functions, and then, understand the algorithm better.
https://github.com/jianminchen/Leetcode_C-/blob/master/99RecoveryBinarySearchTree_C.cs
100 same tree
Two implementations,one recursive, one iterative solution.
https://github.com/jianminchen/Leetcode_C-/blob/master/100SameTree.cs
Leetcode question 80-90
August 22, 2015
80 Remove duplicates from Sorted Array II
81 Search in Rotated Sorted Array II
82 Remove Duplicates from Sorted List II
83 Remove Duplicates from Sorted List
84 Largest Rectangle in Histogram
http://juliachencoding.blogspot.ca/2015/06/leetcode-largest-rectangle-in-histogram.html
85 Maximal Rectangle
86 Partition List
87 Scramble String
http://juliachencoding.blogspot.ca/2015/06/leetcode-scramble-string.html
need to write first C# implementation for the problem.
88 Merge Sorted Array
89 Gray Code
90 Subsets II
80 Remove duplicates from Sorted Array II
81 Search in Rotated Sorted Array II
82 Remove Duplicates from Sorted List II
83 Remove Duplicates from Sorted List
84 Largest Rectangle in Histogram
http://juliachencoding.blogspot.ca/2015/06/leetcode-largest-rectangle-in-histogram.html
85 Maximal Rectangle
86 Partition List
87 Scramble String
http://juliachencoding.blogspot.ca/2015/06/leetcode-scramble-string.html
need to write first C# implementation for the problem.
88 Merge Sorted Array
89 Gray Code
90 Subsets II
Leetcode questions: 70 - 80
August 22, 2015
70 climbing stairs
71 Simplify Path
72 Edit Distance
http://juliachencoding.blogspot.ca/2015/06/leetcode-edit-distance.html
73 Set Matrix Zeroes
74 Search a 2D Matrix
75 Sort Colors
76 Minimum Window Substring
77 Combinations
78 Subsets
79 Word Search
http://juliachencoding.blogspot.ca/2015/07/leetcode-word-search.html
70 climbing stairs
71 Simplify Path
72 Edit Distance
http://juliachencoding.blogspot.ca/2015/06/leetcode-edit-distance.html
73 Set Matrix Zeroes
74 Search a 2D Matrix
75 Sort Colors
76 Minimum Window Substring
77 Combinations
78 Subsets
79 Word Search
http://juliachencoding.blogspot.ca/2015/07/leetcode-word-search.html
Leetcode questions from 41 - 50
August 22, 2015
41 Frist Missing Positive
42 Trapping Rain Water
43 Multiply Strings
44 Wildcard Matching
45 Jump Game II
46 Permutations
47 Permutations II
48 Rotate Image
49 Anagrams
50 Pow(x, n)
http://juliachencoding.blogspot.ca/2015/06/leetcode-powerxn.html
C# implementation:
https://github.com/jianminchen/powerOfN/blob/master/Program.cs
41 Frist Missing Positive
42 Trapping Rain Water
43 Multiply Strings
44 Wildcard Matching
45 Jump Game II
46 Permutations
47 Permutations II
48 Rotate Image
49 Anagrams
50 Pow(x, n)
http://juliachencoding.blogspot.ca/2015/06/leetcode-powerxn.html
C# implementation:
https://github.com/jianminchen/powerOfN/blob/master/Program.cs
Leetcode questions 11 - 20
August 22, 2015
11 Container with Most water
blog:
http://www.cnblogs.com/TenosDoIt/p/3812880.html
C#:
https://github.com/jianminchen/Leetcode_C-/blob/master/11ContainerWithMostWater.cs
12. Integer to Roman
13 Roman to Integer
https://github.com/jianminchen/Leetcode_C-/blob/master/13RomanToInteger.cs
14. LOngest Common Prefix
https://github.com/jianminchen/Leetcode_C-/blob/master/LongestCommonPrefix_No14.cs
15. 3Sum
16 3 Sum Closest
https://github.com/jianminchen/Leetcode_C-/blob/master/3sumCloset.cs
17 Letter Combinations of a phone number (DFS)
http://www.cnblogs.com/grandyang/p/4452220.html
Analysis from the above blog:
这道题让我们求电话号码的字母组合,即数字2到9中每个数字可以代表若干个字母,然后给一串数字,求出所有可能的组合,相类似的题目有 Path Sum II 二叉树路径之和之二,Subsets II 子集合之二,Permutations 全排列,Permutations II 全排列之二,Combinations 组合项, Combination Sum 组合之和和 Combination Sum II 组合之和之二等等。我们用递归Recursion来解,我们需要建立一个字典,用来保存每个数字所代表的字符串,然后我们还需要一个变量level,记录当前生成的字符串的字符个数,实现套路和上述那些题十分类似,
https://github.com/jianminchen/Leetcode_C-/blob/master/LetterCombinationOfAPhoneNumber.cs
18 4 sum
19 Remove Nth Node From End of List
20 Valid Parentheses
http://blog.csdn.net/fightforyourdream/article/details/13011825
C# code:
https://github.com/jianminchen/Leetcode_C-/blob/master/20ValidParentheses.cs
January 20, 2016
https://github.com/jianminchen/Leetcode_C-/blob/master/20ValidParentheses_B.cs
favorite blogs to read: January 20, 2016
http://bangbingsyb.blogspot.ca/2014/11/leetcode-valid-parentheses.html
http://www.acmerblog.com/leetcode-solution-valid-parentheses-6316.html
http://blog.csdn.net/foreverling/article/details/49685177?hmsr=toutiao.io&utm_medium=toutiao.io&utm_source=toutiao.io
http://segmentfault.com/a/1190000003481208
http://harrifeng.github.io/algo/leetcode/valid-parentheses.html
http://www.jiuzhang.com/solutions/valid-parentheses/
So, ready to work on the next algorithm about parentheses:
Leetcode 32: longest valid parentheses -
http://codeganker.blogspot.ca/2014/03/longest-valid-parentheses-leetcode.html
11 Container with Most water
blog:
http://www.cnblogs.com/TenosDoIt/p/3812880.html
C#:
https://github.com/jianminchen/Leetcode_C-/blob/master/11ContainerWithMostWater.cs
12. Integer to Roman
13 Roman to Integer
https://github.com/jianminchen/Leetcode_C-/blob/master/13RomanToInteger.cs
14. LOngest Common Prefix
https://github.com/jianminchen/Leetcode_C-/blob/master/LongestCommonPrefix_No14.cs
15. 3Sum
16 3 Sum Closest
https://github.com/jianminchen/Leetcode_C-/blob/master/3sumCloset.cs
17 Letter Combinations of a phone number (DFS)
http://www.cnblogs.com/grandyang/p/4452220.html
Analysis from the above blog:
这道题让我们求电话号码的字母组合,即数字2到9中每个数字可以代表若干个字母,然后给一串数字,求出所有可能的组合,相类似的题目有 Path Sum II 二叉树路径之和之二,Subsets II 子集合之二,Permutations 全排列,Permutations II 全排列之二,Combinations 组合项, Combination Sum 组合之和和 Combination Sum II 组合之和之二等等。我们用递归Recursion来解,我们需要建立一个字典,用来保存每个数字所代表的字符串,然后我们还需要一个变量level,记录当前生成的字符串的字符个数,实现套路和上述那些题十分类似,
https://github.com/jianminchen/Leetcode_C-/blob/master/LetterCombinationOfAPhoneNumber.cs
18 4 sum
19 Remove Nth Node From End of List
20 Valid Parentheses
http://blog.csdn.net/fightforyourdream/article/details/13011825
C# code:
https://github.com/jianminchen/Leetcode_C-/blob/master/20ValidParentheses.cs
January 20, 2016
https://github.com/jianminchen/Leetcode_C-/blob/master/20ValidParentheses_B.cs
favorite blogs to read: January 20, 2016
http://bangbingsyb.blogspot.ca/2014/11/leetcode-valid-parentheses.html
http://www.acmerblog.com/leetcode-solution-valid-parentheses-6316.html
http://blog.csdn.net/foreverling/article/details/49685177?hmsr=toutiao.io&utm_medium=toutiao.io&utm_source=toutiao.io
http://segmentfault.com/a/1190000003481208
http://harrifeng.github.io/algo/leetcode/valid-parentheses.html
http://www.jiuzhang.com/solutions/valid-parentheses/
So, ready to work on the next algorithm about parentheses:
Leetcode 32: longest valid parentheses -
http://codeganker.blogspot.ca/2014/03/longest-valid-parentheses-leetcode.html
Friday, August 21, 2015
Leetcode questions from 61 - 69
August 21, 2015
Speed up study leetcode questions, 10 question a time, in 2-3
hours. And see if I can learn something quickly.
61 Rotate List
http://bangbingsyb.blogspot.ca/2014/11/leetcode-rotate-list.html
julia's C# implementation practice:
https://github.com/jianminchen/Leetcode_C-/blob/master/61RotateList.cs
julia's C# implementation practice:
https://github.com/jianminchen/Leetcode_C-/blob/master/61RotateList.cs
62 Unique Paths
DP algorithm in detail, time complexity and space complexity
analysis is great in the following blog:
63 Unique Paths II
64 Minimum Path Sum
discussion of using 2 dimension array or using one dimension
array, still not clear.
understand this blog on DP solutions, one is space O(n^2), one is
space O(n).
65 Valid number
ideas for the solution from the following blog:
3 flags are set: num, exp, dot, and then,
1. if there is e flag, then there is a digit before e flag,
cannot have any e.
Also, there is a digit followed.
2. if . shows up, then it is a small fraction number, so
neither . nor e is before .
3. if +, -, then it must be first one, or the previous on is
e,
for example: "005047e+6".
The above summary is from the following blog:
code is here:
Julia's C# code practice:
https://github.com/jianminchen/Leetcode_C-/blob/master/65ValidNumber.cs
blogs:
https://leetcodenotes.wordpress.com/2013/11/23/leetcode-valid-number/
http://www.cnblogs.com/TenosDoIt/p/3475305.html
http://www.cnblogs.com/chasuner/p/validNumber.html
https://github.com/fuwutu/LeetCode/blob/master/Valid%20Number.cpp
http://rleetcode.blogspot.ca/2014/01/valid-number-java.html
https://github.com/jianminchen/Leetcode_C-/blob/master/65ValidNumber.cs
blogs:
https://leetcodenotes.wordpress.com/2013/11/23/leetcode-valid-number/
http://www.cnblogs.com/TenosDoIt/p/3475305.html
http://www.cnblogs.com/chasuner/p/validNumber.html
https://github.com/fuwutu/LeetCode/blob/master/Valid%20Number.cpp
http://rleetcode.blogspot.ca/2014/01/valid-number-java.html
66 Plus number
67 Add Binary
Totally forget I did this implementation. So, I have to learn everything about this problem again, read more blogs this time.
https://github.com/jianminchen/addBinary/blob/master/Program.cs
my favorite solution is the following blog:
http://fisherlei.blogspot.ca/2013/01/leetcode-add-binary.html
julia's C# code:
https://github.com/jianminchen/Leetcode_C-/blob/master/67AddBinary2.cs
http://bangbingsyb.blogspot.ca/2014/11/leetcode-add-binary.html
the code should be more short, but the discussion and idea in the code is very clear.
http://siddontang.gitbooks.io/leetcode-solution/content/string/add_binary.html
Good quality code, try it myself later.
http://www.jiuzhang.com/solutions/add-binary/
julia's c# implementation:
https://github.com/jianminchen/Leetcode_C-/blob/master/67AddBinary.cs
https://github.com/jianminchen/addBinary/blob/master/Program.cs
my favorite solution is the following blog:
http://fisherlei.blogspot.ca/2013/01/leetcode-add-binary.html
julia's C# code:
https://github.com/jianminchen/Leetcode_C-/blob/master/67AddBinary2.cs
http://bangbingsyb.blogspot.ca/2014/11/leetcode-add-binary.html
the code should be more short, but the discussion and idea in the code is very clear.
http://siddontang.gitbooks.io/leetcode-solution/content/string/add_binary.html
Good quality code, try it myself later.
http://www.jiuzhang.com/solutions/add-binary/
julia's c# implementation:
https://github.com/jianminchen/Leetcode_C-/blob/master/67AddBinary.cs
68 Text Justification
69 sqrt(x)
http://yucoding.blogspot.ca/2013/03/leetcode-question-102-sqrtx.html
http://codeganker.blogspot.ca/2014/02/sqrtx-leetcode.html
C# implementation:
https://github.com/jianminchen/Leetcode_C-/blob/master/69Sqrt(x).cs
http://yucoding.blogspot.ca/2013/03/leetcode-question-102-sqrtx.html
http://codeganker.blogspot.ca/2014/02/sqrtx-leetcode.html
C# implementation:
https://github.com/jianminchen/Leetcode_C-/blob/master/69Sqrt(x).cs
70 Climbing Stairs
http://juliachencoding.blogspot.ca/2015/07/leetcode-climbing-stairs.html
Thursday, August 20, 2015
Leetcode questions quick review from No. 30 - 40
August 19, 2015
30 Substring with Concatenation of All Words
http://segmentfault.com/a/1190000002625580
http://bangbingsyb.blogspot.ca/2014/11/leetcode-search-for-range.html
31 Next Permutation
32 Longest Valid Parentheses
http://codeganker.blogspot.ca/2014/03/longest-valid-parentheses-leetcode.html
http://bangbingsyb.blogspot.ca/2014/11/leetcode-longest-valid-parentheses.html
http://blog.csdn.net/worldwindjp/article/details/39460161
http://shanjiaxin.blogspot.ca/2014/04/longest-valid-parentheses-leetcode.html
C# code:
https://github.com/jianminchen/Leetcode_C-/blob/master/32LongestValidParentheses.cs
33 Search in Rotated Sorted Array
34 search for range
http://bangbingsyb.blogspot.ca/2014/11/leetcode-search-for-range.html
35 Search Insert Position
36 Valid Sudoku
37 Sudoku Slover
Try 10 various implementations:
http://juliachencoding.blogspot.ca/2015/07/leetcode-sudoku-solver.html
38 count and say
http://www.cnblogs.com/springfor/p/3889221.html
39 Combination Sum
40 Combination Sum II
30 Substring with Concatenation of All Words
http://segmentfault.com/a/1190000002625580
http://bangbingsyb.blogspot.ca/2014/11/leetcode-search-for-range.html
31 Next Permutation
32 Longest Valid Parentheses
http://codeganker.blogspot.ca/2014/03/longest-valid-parentheses-leetcode.html
http://bangbingsyb.blogspot.ca/2014/11/leetcode-longest-valid-parentheses.html
http://blog.csdn.net/worldwindjp/article/details/39460161
http://shanjiaxin.blogspot.ca/2014/04/longest-valid-parentheses-leetcode.html
C# code:
https://github.com/jianminchen/Leetcode_C-/blob/master/32LongestValidParentheses.cs
33 Search in Rotated Sorted Array
34 search for range
http://bangbingsyb.blogspot.ca/2014/11/leetcode-search-for-range.html
35 Search Insert Position
36 Valid Sudoku
37 Sudoku Slover
Try 10 various implementations:
http://juliachencoding.blogspot.ca/2015/07/leetcode-sudoku-solver.html
38 count and say
http://www.cnblogs.com/springfor/p/3889221.html
39 Combination Sum
40 Combination Sum II
Tuesday, August 18, 2015
Leetcode question 20 - 30
August 18, 2015
Work on those ten questions quickly, spend 20 minutes on each question; Do not over analyze the problem, try to get basic idea and implementation tips through blogs first.
22 Generate Parentheses
https://github.com/jianminchen/Leetcode_C-/blob/master/GenerateParentheses_No22.cs
23 Merge K Sorted Lists
https://github.com/jianminchen/Leetcode_C-/blob/master/MergeKSortedLists_A_No23.cs
https://github.com/jianminchen/Leetcode_C-/blob/master/MargeKSortedLists_B_No23.cs
24 Swap nodes in pairs
https://github.com/jianminchen/Leetcode_C-/blob/master/24SwapNodesInPairs.cs
C# implementation:
https://github.com/jianminchen/Leetcode_C-/blob/master/24SwapNodesInPairs.cs
25 Reverse Nodes in k-Group
26 Remove Duplicates from Sorted Array
27 Remove Element
28 Implement strStr()
29 Divide Two Integers
30 Substring with Concatenation of All Words
Work on those ten questions quickly, spend 20 minutes on each question; Do not over analyze the problem, try to get basic idea and implementation tips through blogs first.
22 Generate Parentheses
https://github.com/jianminchen/Leetcode_C-/blob/master/GenerateParentheses_No22.cs
23 Merge K Sorted Lists
https://github.com/jianminchen/Leetcode_C-/blob/master/MergeKSortedLists_A_No23.cs
https://github.com/jianminchen/Leetcode_C-/blob/master/MargeKSortedLists_B_No23.cs
24 Swap nodes in pairs
https://github.com/jianminchen/Leetcode_C-/blob/master/24SwapNodesInPairs.cs
C# implementation:
https://github.com/jianminchen/Leetcode_C-/blob/master/24SwapNodesInPairs.cs
25 Reverse Nodes in k-Group
26 Remove Duplicates from Sorted Array
27 Remove Element
28 Implement strStr()
29 Divide Two Integers
30 Substring with Concatenation of All Words
Sunday, August 16, 2015
Leetcode questions 1 - 10
August 15
1. Two sum
C#
https://github.com/jianminchen/Leetcode_C-/blob/master/1TwoSum.cs
9 Palindrome number
blog:
http://codeganker.blogspot.ca/2014/02/palindrome-number-leetcode.html
C# code:
https://github.com/jianminchen/Leetcode_C-/blob/master/9palindromeNumber.cs
10 Regular Expression Matching
blog:
http://bangbingsyb.blogspot.ca/2014/11/leetcode-regular-expression-matching.html
C# code:
https://github.com/jianminchen/Leetcode_C-/blob/master/10RegularExpressionMatching.cs
1. Two sum
C#
https://github.com/jianminchen/Leetcode_C-/blob/master/1TwoSum.cs
2. Add two numbers
C#
https://github.com/jianminchen/Leetcode_C-/blob/master/2AddTwoNumbers.cs
3. Longest substring without repeating characters
blog:
http://blog.csdn.net/linhuanmars/article/details/19949159
read all the comments, and play with code using C#, at least 20 minutes; get more understanding this time.
https://github.com/jianminchen/Leetcode_C-/blob/master/3LongestSubstringWithoutRepeating.cs
4. Median of two sorted array (8/17/2015)
C# implementation:
https://github.com/jianminchen/Leetcode_C-/blob/master/4MedianOfTwoSortedArrays.cs
5 longest palindromic substring
C#
https://github.com/jianminchen/Leetcode_C-/blob/master/5LongestPalindromicSubstring.cs
C#
https://github.com/jianminchen/Leetcode_C-/blob/master/2AddTwoNumbers.cs
3. Longest substring without repeating characters
blog:
http://blog.csdn.net/linhuanmars/article/details/19949159
read all the comments, and play with code using C#, at least 20 minutes; get more understanding this time.
https://github.com/jianminchen/Leetcode_C-/blob/master/3LongestSubstringWithoutRepeating.cs
4. Median of two sorted array (8/17/2015)
C# implementation:
https://github.com/jianminchen/Leetcode_C-/blob/master/4MedianOfTwoSortedArrays.cs
5 longest palindromic substring
C#
https://github.com/jianminchen/Leetcode_C-/blob/master/5LongestPalindromicSubstring.cs
9 Palindrome number
blog:
http://codeganker.blogspot.ca/2014/02/palindrome-number-leetcode.html
C# code:
https://github.com/jianminchen/Leetcode_C-/blob/master/9palindromeNumber.cs
10 Regular Expression Matching
blog:
http://bangbingsyb.blogspot.ca/2014/11/leetcode-regular-expression-matching.html
C# code:
https://github.com/jianminchen/Leetcode_C-/blob/master/10RegularExpressionMatching.cs
Thursday, August 13, 2015
Leetcode: questions and favorite blogs
August 13, 2015,
Go over the leetcode questions one by one, find one blog/ more to help me fully understand the problem. 改变学习方法, 广度优先, 多做题, 保持一定速度, 接触新的题目; 先看题解, 直接看代码; 一个小时学习二道题的速度.
23 Merge k Sorted Lists hard
(just do it) http://www.cnblogs.com/TenosDoIt/p/3673188.html
22 Generate Parentheses
(fight for dream) http://blog.csdn.net/fightforyourdream/article/details/14159435
http://blog.csdn.net/linhuanmars/article/details/19873463 (more easy to understand) (one line error)
21 Merge two sorted lists
http://www.cnblogs.com/springfor/p/3862040.html (show how to optimize the code! Very good. )
22 valid parentheses
easy
19 remove Nth node from End of List
http://www.cnblogs.com/springfor/p/3862219.html
(very clever tip for faster pointer)
Here are C# code folder:
https://github.com/jianminchen/Leetcode_C-
Here are C# code folder:
https://github.com/jianminchen/Leetcode_C-
Wednesday, August 12, 2015
Blogging benefits
Julia likes to keep her own research on writing benefits as a software programmer. So, she keeps the log of her research.
August 12, 2015
Read two articles about benefits about blogging as a software programmer. Great ideas in the blog.
http://kb.cnblogs.com/page/517038/
http://kb.cnblogs.com/page/526625/
Dec. 17, 2015
Take some notes from above blogs:
Note:
1. Learn to listen; person can sense if you listen, respect him/her; wait until he/she finishes the talking.
2. Always be a big tipper. Sign of respect. Always be nice to helper.
3. Always call your mother. I wish I can call mine.
January 12, 2015
https://www.youtube.com/watch?v=R22dJ7bn-pU&list=PLgYNPs-V9YFPqcnEvbIy5hFE40BjxMbjw&index=2
A person loves to write, then the person must love to read, and then, the person must be intellect curious. That is one of 5 things in the talk:
1. intellect value
- how we judge people - how we collaborate - highly collaborate - not collaborate - collaboration - need to know that, how to measure
fast/decisive - consensus - relationship - seek colloaborate
value in your business - big company
3. conformity -
4. Motivation -
5. Experience -
High performance -
March 23, 2016
http://onstartups.com/tabid/3339/bid/14208/Why-Every-Entrepreneur-Should-Write-and-9-Tips-To-Get-Started.aspx
http://www.c-sharpcorner.com/article/why-every-developer-should-write/
August 12, 2015
Read two articles about benefits about blogging as a software programmer. Great ideas in the blog.
http://kb.cnblogs.com/page/517038/
http://kb.cnblogs.com/page/526625/
Dec. 17, 2015
Take some notes from above blogs:
提高自己对知识的掌握层次
美国教育心理学家Bloom将知识认知分为了两个维度,其中认知历程维度又分为6个层次, 由低到高,分别为:记忆、理解、应用、分析、评鉴、创造。层次越高,表示对知识的掌握程度越深。
提高表达和沟通的能力
接受读者的沟通和反馈
影响力
January 3, 2015Thomas Friedman: Lessons Learned After 20 Years of Writing Columns
https://www.youtube.com/watch?v=dxXx3XvNVWA&list=PLxq_lXOUlvQAwaY_9K4ZFH9Xdar9WzCaL&index=19Note:
1. Learn to listen; person can sense if you listen, respect him/her; wait until he/she finishes the talking.
2. Always be a big tipper. Sign of respect. Always be nice to helper.
3. Always call your mother. I wish I can call mine.
January 12, 2015
Hiring Rockstars by Roger Philby
https://www.youtube.com/watch?v=R22dJ7bn-pU&list=PLgYNPs-V9YFPqcnEvbIy5hFE40BjxMbjw&index=2A person loves to write, then the person must love to read, and then, the person must be intellect curious. That is one of 5 things in the talk:
1. intellect value
- how we judge people - how we collaborate - highly collaborate - not collaborate - collaboration - need to know that, how to measure
fast/decisive - consensus - relationship - seek colloaborate
value in your business - big company
3. conformity -
4. Motivation -
5. Experience -
High performance -
March 23, 2016
http://onstartups.com/tabid/3339/bid/14208/Why-Every-Entrepreneur-Should-Write-and-9-Tips-To-Get-Started.aspx
http://www.c-sharpcorner.com/article/why-every-developer-should-write/
Julia's reading list of CSS, html, Java Script
CSS/ Jquery/ Html reading list
Julia read several articles to expand knowledge about CSS, html, Java Script, and here is her reading list compiled on August 12, 2015:
- August 28, 2013
Read the article web standards curriculum
- May 9, 2013, read the article, and then memorize the selectors.
- Visual formatting model (August 26, 2013):
- CSS 2.1 primer
- Cascading Style Sheets articles and tutorials (August 28, 2013)
- Inheritance and cascade (Nov. 18, 2013): (learning specificity calculation in detail)
- Basic Structures of a web page (Nov. 27, 2013):
- CSS absolute and fixed positioning (Nov. 20, 2013)
- Javascript Guide (Mozzila Foundation US)
- CSS pocket book: (March 24, 2015)
Monday, August 10, 2015
Java Script book reading and videos
August 10, 2015
Spent 12 months starting from January 2014 to study Java Script, it is most challenging language I learned and finally get used to this functional language, dynamic, loosely type language. Enjoy reading the Java Script code and play with the code.
Here are some resources most helpful to my personal experience:
Books I read, some of them only a few pages here and there:
- [O`Reilly] - JavaScript. The Definitive Guide, 6th ed. - [Flanagan]
Only read 200 pages of the book (total pages: around 1000 pages), spent 2-3 months to read, practice
- JavaScript for PHP Developers
Tried examples in the book, and practiced some. Focused on first 3 chapters. Great book!
- JavaScript Patterns
- Javascript cookbook
- [Manning] - Secrets of the JavaScript Ninja - [Resig]
- O'reilly - Head First Javascript
- Maintainable JavaScript
- Java Script good parts
- Testable JavaScript (one of my favorite books)
Videos I watched:
- Douglas Crokford: The Javascript Programming language and most of the videos from him on Youtube.com
- Learning to love Javascript and a lot of other google videos about Javascript
Leetcode: Maximum product subarray
August 10, 2015
Find the contiguous subarray within an array (containing at least one number)
which has the largest product.
which has the largest product.
For example, given the array [2,3,-2,4],
the contiguous subarray [2,3] has the largest product = 6.
the contiguous subarray [2,3] has the largest product = 6.
Two approaches, one is dynamic programming DP implementation, another is the greedy method.
DP solution:
Greedy algorithm:
read the blog first,
http://fmarss.blogspot.ca/2014/10/leetcode-solution-maximum-product.html
and then, convert it to C# programming language,
read the blog first,
http://fmarss.blogspot.ca/2014/10/leetcode-solution-maximum-product.html
and then, convert it to C# programming language,
Saturday, August 8, 2015
Leetcode 239: sliding window maximum
August 7, 2015
Julia spent 20-30 minutes to think about solution first, and read the following blogs, write some code as well. She practised three time using C# and here are the details.
Here are 3 practice Julia did using LinkedList, List and SortedList.
C# practices
Here are 3 practice Julia did using LinkedList, List and SortedList.
1. C# LinkedList
C# code implementation
2. C# List<int>
3. C# SortedList
More detail
Double ended queue is implemented using C# LinkedList class, here is Julia's C# practice code: C# code implementationJulia chose to study the blog on Leetcode: sliding window maximum
C# code implementation (C# does not have deque class, so using C# List<int>,
convert Python code implementation to C#, time limit exceeded)
Good workout on C# List<int>, Julia experienced different style on removing head element if out of sliding window.
Julia chose to read the blog on geekforgeek.com called "maximum of all subarrays of size k".
Method A: naive solution, time complexity O(nw)
C# practice code is here.
C# practice code is here.
Method B: using Self-Balancing Tree (Time complexity: O(nk), need to write c# code)
C# practice code is here.
C# practice code is here.
4. blog:
http://n00tc0d3r.blogspot.ca/2013/04/sliding-window-maximum.html
Good comment about Deque:
We can use a Deque which allow insertions/deletions on both ends. For a Deque implemented by Circular Array/Buffer or Double Linked List, the basic insert/delete operations run in constant time.
discussion of using heap:
The first thought might be heap.
By maintaining a heap for all numbers in the window can give us a O(nlogw)-time solution, where
- building up a heap for initial window takes time O(wlogw)
- when window moves to the next number, each insertion and deletion take time O(logw) and there are n-w moves in total.
- after updating the heap, findMax only takes time O(1) since we know the top of heap is the largest.
So, if w << n, the performance of this solution is good, close to O(n); but if w is not that small, say w = n/3 or n/4, the running time goes up to O(nlogn).
C# practice code
6. blog:
http://www.mamicode.com/info-detail-927510.html
Convert Java Script code to C#; I spent over 12 months to try to be expert on Java Script, so much fun to read the Java Script code again, and enjoyed the blog about the analysis.
Others:
https://github.com/jianminchen/slidingWindowMaximum/blob/master/slidingWindowMaximu5.cs
Wednesday, August 5, 2015
Leetcode questions and web link
August 5, 2015
Here is the table about leetcode questions:
Here is the table about leetcode questions:
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
|
28
|
|
29
|
|
30
|
|
31
|
|
32
|
|
33
|
|
34
|
|
35
|
|
36
|
|
37
|
|
38
|
|
39
|
|
40
|
|
41
|
|
42
|
|
43
|
|
44
|
|
45
|
|
46
|
|
47
|
|
48
|
|
49
|
|
50
|
|
51
|
|
52
|
|
53
|
|
54
|
|
55
|
|
56
|
|
57
|
|
58
|
|
59
|
|
60
|
|
61
|
|
62
|
|
63
|
|
64
|
|
65
|
|
66
|
|
67
|
|
68
|
|
69
|
|
70
|
|
71
|
|
72
|
|
73
|
|
74
|
|
75
|
|
76
|
|
77
|
|
78
|
|
79
|
|
80
|
|
81
|
|
82
|
|
83
|
|
84
|
|
85
|
|
86
|
|
87
|
|
88
|
|
89
|
|
90
|
|
91
|
|
92
|
|
93
|
|
94
|
|
95
|
|
96
|
|
97
|
|
98
|
|
99
|
|
100
|
|
101
|
|
102
|
|
103
|
|
104
|
|
105
|
|
106
|
|
107
|
|
108
|
|
109
|
|
110
|
|
111
|
|
112
|
|
113
|
|
114
|
|
115
|
|
116
|
|
117
|
|
118
|
|
119
|
|
120
|
|
121
|
|
122
|
|
123
|
|
124
|
|
125
|
|
126
|
|
127
|
|
128
|
|
129
|
|
130
|
|
131
|
|
132
|
|
133
|
|
134
|
|
135
|
|
136
|
|
137
|
|
138
|
|
139
|
|
140
|
|
141
|
|
142
|
|
143
|
|
144
|
|
145
|
|
146
|
|
147
|
|
148
|
|
149
|
|
150
|
|
151
|
|
152
|
|
153
|
|
154
|
|
155
|
|
156
|
|
157
|
|
158
|
|
159
|
|
160
|
|
161
|
|
162
|
|
163
|
|
164
|
|
165
|
|
166
|
|
167
|
|
168
|
|
169
|
|
170
|
|
171
|
|
172
|
|
173
|
|
174
|
|
179
|
|
186
|
|
187
|
|
188
|
|
189
|
|
190
|
|
191
|
|
198
|
|
199
|
|
200
|
|
201
|
|
202
|
|
203
|
|
204
|
|
205
|
|
206
|
|
207
|
|
208
|
|
209
|
|
210
|
|
211
|
|
212
|
|
213
|
|
214
|
|
215
|
|
216
|
|
217
|
|
218
|
|
219
|
|
220
|
|
221
|
|
222
|
|
223
|
|
224
|
|
225
|
|
226
|
|
227
|
|
228
|
|
229
|
|
230
|
|
231
|
|
232
|
|
233
|
|
234
|
|
235
|
|
236
|
|
237
|
|
238
|
|
239
|
|
240
|
|
241
|
|
242
|
|
243
|
|
244
|
|
245
|
|
246
|
|
247
|
|
248
|
|
249
|
|
250
|
|
251
|
Subscribe to:
Posts (Atom)