May 31, 2016
Review the blog:
http://juliachencoding.blogspot.ca/2015/06/leetcode-zigzag-order-traversal-of.html
practice in 2015:
https://github.com/jianminchen/zigzagOrderTraversal/blob/master/Program.cs
Warmup practice on May 31, 2016, write a C# solution again:
https://gist.github.com/jianminchen/3723020cd9757f85d0ceb383da425c6c
Practice notes:
1. source code line 107 , Stack, use ref, pass reference.
Lookup why Stack is different from Array. Array reference is passed automatically.
Read the blog:
http://stackoverflow.com/questions/967402/are-arrays-or-lists-passed-by-default-by-reference-in-c
2. Extract a function named swap(), actually, the last practice:
https://github.com/jianminchen/zigzagOrderTraversal/blob/master/Program.cs
line 57, Stack<int> tmp is declared, but line 92 tmp is used. The scope is too large to pay attention. So, extract it to a function.
3. The last practice first while loop on line 59:
https://github.com/jianminchen/zigzagOrderTraversal/blob/master/Program.cs
It is confusing, so in current practice, line 72, while(true),
line 72: while(true)
later, on line 112, break the while loop.
line 112: if (currLevel == null || currLevel.Count == 0)
113: break;
4. line 61, if (root == null), return empty list instead of null pointer.
Nov. 14, 2016
Google/Bing Search Result:
zig-zag traversal of a binary tree in c
Review the blog, and then, need to document about array reference passing in C#, see stackoverflow article:
http://stackoverflow.com/questions/12757841/are-arrays-passed-by-value-or-passed-by-reference-in-java
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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment