Wednesday, August 5, 2015

Leetcode questions and web link

August 5, 2015

  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

Sunday, August 2, 2015

Leetcode study time

August 2, 2015

在http://zzk.cnblogs.com/ 用"找一找", 花了几个小时, 找出比较好的Leetcode博客.

Read the leetcode question and solutions:

1. Find lowest common ancestor in binary tree:

blog of a facebook programmer working on leetcode questions:

递归版本:空间O(1),时间O(n)

http://www.cnblogs.com/chkkch/archive/2012/11/26/2788795.html

Try it myself and compare to solutions in my blog:
http://juliachencoding.blogspot.ca/2015/07/leetcode-lowest-common-ancestor-in.html

2. Reverse nodes in k group

http://www.cnblogs.com/lichen782/p/leetcode_Reverse_Nodes_in_kGroup.html

http://www.cnblogs.com/grandyang/p/4606710.html


3.  binary tree

http://www.cnblogs.com/wwwjieo0/p/3891037.html

4. All 158 leetcode algorithm implementation in git hub:

http://coolshell.cn/articles/1870.html

Leetcode solution on git hub (use this one more often, best answer, author profile: http://coolshell.cn/haoel)

https://github.com/haoel/leetcode/tree/master/algorithms

5. Leetcode using C#

https://github.com/xisuogu/LeetSharp/tree/master/LeetSharp

6. One more to read



http://blog.csdn.net/u014674776/article/category/2296455

辛苦了几个小时, 总算可以出门放松,打打网球,准备明日爬山了!



Tuesday, July 28, 2015

CSS, JavaScript, Jquery learning

July 27, 2015

Basic training code for CSS, html, Jquery, Javascript from books, public internet, and other people's blog. Training basics, know concepts.  

Learning a new language takes time, know syntax, memorize CSS selectors, and then, read "Head first CSS" and understand basic box model, rules, cascading rules, specificity in CSS etc.; she should have stayed more organized.

She tries to learn more about CSS, html, Java Script, practice more code. 







My favorite thing to do is to challenge myself, try to memorize something over 10 times and see if it will help me learn a new language, improve programming performance. 

Java Script cheat sheet from book Pocket Guide To JavaScript is my favorite one to read, and practice to memorize. 
Here is another one: 
http://www.cheatography.com/davechild/cheat-sheets/javascript/



SQL Server DBA, database design, and development

July 28, 2015

SQL server DBA most popular guidelines for self-learner:

1.       Database may be set up simple transaction log, so the database can be fixed size; never worry about disk space;

2.      Back up database every day; no pressure to work on live database update; certainly, reduce risk to manual update record one by one instead of update statement. 

Also, the website to find the SQL performance script to do daily monitor using database mail setup, so database disk space, backup log, auto growth log, and all other activity can be helpful for every morning.

Here is her favorite site to get the SQL script:


Never too later to share her thoughts and great ideas with outside world, also her first blog about SQL server DBA experience.

Leetcode Question No 70: climbing stairs

July 28, 2015

Problem statement:
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

The problem is most popular question in the algorithm, so I do like to spend time to find out all sorts of solution, and get myself comfortable to all kinds of ideas, and figure out which one is best, and all concerns we can have in the discussion of climbing stairs:

1. Recursion solution vs. DP problem solution (Dynamic Programming solution)
2. Time complexity solution: O(2^n) vs O(n) solution
3. The space O(N) vs O(1), in other words: array of N or 2 variable, and another tmp variable
4. The base case discussion: f(0) = 1 or f(0) =1, math question?
5. Math formula - closed form solution vs DP problem solution
6. Use Memoization DP vs. no memoization DP
7. Programming skills, how to make code easy to follow, more readable, more abstract. 

The investment of time on the problem is well done. Go over 16 implementation one by one using C# programming language. 

C# code:

其实, 我觉得题目越容易, 越值得投入时间去学习; 看看大家有没有不同的理解, 打开思路; 如果自己没有训练过这道题, 可能会紧张; 即使训练过, 但是, 有的想法, 可能自己从来没有思考过, 一时还不能判断好坏, 但是, 多看网上的博客, 向每一个人取取经. 谦虚, 才能有提高.

我编网站后台, C#程序自己写; 自己训练的题目太少; 这次选择用Leetcode来提高C#编程, 又可以提高算法和数据结构的知识, 网站后台靠平时训练.  

January 3, 2016
Review the leetcode question 70, climbing stairs. 
Read the blog:
http://blog.csdn.net/kenden23/article/details/17377869
http://yucoding.blogspot.ca/2012/12/leetcode-question-15-climbing-stairs.html

http://www.cnblogs.com/springfor/p/3886576.html

http://www.cnblogs.com/springfor/p/3886576.html

http://siddontang.gitbooks.io/leetcode-solution/content/dynamic_programming/climbing_stairs.html

https://github.com/zwxxx/LeetCode/blob/master/Climbing_Stairs.cpp



Sunday, July 26, 2015

Saturday, July 25, 2015

Leetcode 238: Product of Array except itself

July 24, 2015

 Introduction



I like to share the article talking about Google interview written in Chinese. The article is called "死理性派教你做谷歌面试题", the link is here. 

The experience of working on Leetcode is so challenging. I fully understand the solution but after a few days, I have no clue how it works. But there are so many good articles to read. 

Leetcode 238 in Chinese



  转载上面网页最后一段.

  不同于上面的“流传”,下面两道是已被确认了的google面试题。
第一题,给你一个长度为 N 的链表。N 很大,但你不知道 N 有多大。你的任务是从这 N 个元素中随机取出 k 个元素。你只能遍历这个链表一次,且必须保证取出的元素是完全随机的(出现概率均等)。
第二题,给你一个数组 A [ 1 .. n ] ,请你在 O ( n ) 的时间里构造一个新的数组 B [ 1 .. n ] ,使得 B [ i ] = A [ 1 ] * A [ 2 ] * ... * A [ n ]/A [ i ] 。你不能使用除法运算。
这两道题目看起来很专业,但有趣的是,即使没有学过信息学的人也可以想到答案。
第一题的意思就是有一大串物品,它们能且仅能逐个经过你眼前一次。你不知道它们的个数,要求你从中随机地抽取 k 个物品,同时必须保证取出的元素是完全随机的(出现概率均等)。
第二题给出了一个数列 A [ 1 .. n ] ,要求在较短的时间内不用除法构造一个新数列 B [ 1 .. n ] ,使得 B [i] = A [ 1 ] * A [ 2 ] * ... * A [ n ]/A [ i ] 。 n是这个数组的长度。而 O ( n ) 是评判计算方法速度的标准。如果一个解答方法在n任意变化的情况下,都能满足总共的计算次数相当于是 n 乘以一个常数C这个条件,那么就称这个解答方法是 O ( n ) 的;如果这个解答方法能满足总共的计算次数是 n 2 乘以常数C,那么这个解答方法就被称作是 O ( n 2 ) 的。
第一题没有告诉我们物品的个数N,所以我们没法算出 k/N,连最基本的每样物品被选中的概率都不知道,还怎么继续操作呢?既然我们不知道一共有多少个物品,那我们就应该在所有的物品都经过我们眼前之后再做抉择。当每个物品经过我们眼前的时候,可以设法对应地给它生成一个 0 到 1 之间的随机数。等到我们见过了所有的物品之后,只需要选择对应的随机数最大的前 k 个物品就行了。
第二题不允许用除法增加了不少难度。 B [ i ] 不用除法来表示的话就是: B [ i ] = A [ 1 ] * ... * A [ i - 1 ] * A [ i + 1 ] * ... * A [ n ] 。若按照这个表达式进行计算,生成每个 B[ i ] 的时候要进行n - 1次乘法,这样一来完全生成 B [ 1 .. n ] 就需要 O ( n 2 ) 的时间了。我们需要通过减少重复的运算来提高效率。
注意到 B [ i ] 可以看作是两个部分的乘积, A [ 1 ] * ... * A [ i - 1 ] 和 A [ i + 1 ] * ... * A [ n ] 。同理 B [ i + 1 ] 就由 A [ 1 ] * ... * A [ i - 1 ] * A [ i ] 和 A [ i + 2 ] * ... * A [ n ] 组成。计算 B [ i ] 时的许多乘法在计算 B [ i + 1 ] 的时候又进行了一遍,因此可以重复利用上一次运算的结果,以避免无谓的运算。从这点出发,我们构造两个新的数列:
S [ i ] = A [ 1 ] * ... * A [ i – 1 ]
T [ i ] = A [ i + 1 ] * ... * A [ n ]
因为生成完整的 S [ 1 .. n ] 和 T [ 1 .. n ] 都能在 O ( n ) 的时间内完成,那么根据 B [ i ] = S [ i ] * T [ i ] 这条式子,生成整个 B [ 1 .. n ] 便也能够在 O ( n ) 的时间内完成了。
不得不说,谷歌是个很爱玩的公司。它曾在MIT校园内到处张贴着一份密码,据说,这份密码包含了一个Google Jobs的电话号码,解开密码的人可以通过此电话留下自己的个人信息,进入谷歌工作。各位读者,你能解开这个密码吗?如果有漂亮的解答,我会在这里贴出来。