Instantly share code, notes, and snippets.

View PostOrderIterative_FinalCode.py
#The interviewee went over the example of tree, explained the algorithm to me.
1
/ \
2 3
\
4
/
5
#After the visit:
View PostOrderIterative.py
class Solution:
def postorderTraversal(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
stack = [root]
res = []
View 623AddOneRowToTree.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _623_Add_one_row_to_tree
{
public class TreeNode
{
View 927ThreeEqualParts_SecondSubmission.cs
public class Solution {
public int[] ThreeEqualParts(int[] digits)
{
if (digits == null)
return new int[] {-1, - 1};
var countof1 = 0;
var length = digits.Length;
var map = new Dictionary<int, int>();
for(int i = 0; i < length; i++)
View 927ThreeEqualParts_FirstSubmission.cs
public class Solution {
public int[] ThreeEqualParts(int[] digits)
{
if (digits == null)
return new int[] {-1, - 1};
var countof1 = 0;
var length = digits.Length;
var map = new Dictionary<int, int>();
for(int i = 0; i < length; i++)
View longest univalue path - hints to help
Leetcode: longest univalue path
hint:
instead of working on longest path directly, kind of greedy, break into two parts.
length1 = one is the root to leaf node longest path -> left side
length2 = one is the root to leaf node longest path -> right side
path cross the root = length1 + length2
View CompleteBinaryTreeInserter.cs
using System;
// To execute C#, please define "static void Main" on a class
// named Solution.
class Solution
{
static void Main(string[] args)
{
for (var i = 0; i < 5; i++)
View Email wrote in 2007
Sent: Tuesday, September 25, 2007 10:22 AM
To: iSiva Team Zissou
Hi, folks,
I like to share some thoughts about maintenance of our Siva legacy code and new feature development.
20% bugs I fixed is related to Run Time Type Checking Exception. If we are good at code style, we can
avoid it in less than 10 minutes. But if we troubleshooting or expand the feature, it takes hours or even a day.
View How to work on Leetcode algorithms
http://www.1point3acres.com/bbs/thread-446715-1-1.html
狗家 offer 已签,分享下心得和 filter
Leetcode:第一遍 250,按顺序的 1 - 250。
第一遍建议先按题目类型的 tag 刷,把前 200/250/300/… 的题都认真写一遍。discussion board 一定要看。
第二遍 280,按 company tag 和面筋刷的。
Leetcode 会员一定要买,不要因小失大。第二遍刷的时候,不要死扣 accepted or not。重要的是思路,一道题思路明白了,edge case 分析清楚,代码写的像模像样就行了。如果能 accepted 最好,如果思路是对的,代码也看着 okay,但是就是有 bug 跑不出来。千万不要浪费太多时间在 debug 上,直接去 discussion board 复制答案提交,标记成做过的就行了。因为 interviewer,hc 都不会跑你的代码!切记,重要的是思路!
时间的话,我训练的标准是 easy 10 mins,medium 20 mins, hard 30 mins。如果没有按时写完,用 easy 5m, medium 10m, hard 15m 的时间看 discussion board。如果还没看懂,就把题目记下来,以后多看几遍。
View DrawCircle.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DrawACircle
{
class DrawACircle
{