Coding Style

  1. Leave blank space around each operations
  2. Give meaningful names to parameters
  3. Add space line between two logic blocks

For example, Implement strStr():

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
public class Solution {
public String strStr(String haystack, String needle) {
if(haystack.length() < needle.length()) {
return null;
}
if(haystack == null || needle == null || needle.length() == 0) {
return haystack;
}

for(int i = 0; i <= haystack.length() - needle.length(); i++) {
boolean find = true;
for(int j = 0; j < needle.length(); j++) {
if(haystack.charAt(i + j) != needle.charAt(j)) {
find = false;
break;
}
}
if(find == true) {
return haystack.substring(i);
}
}

return null;
}
}

Tips: A well-known algorithm to solve this problem is using KMP. This method can run in O(m+n) time. But usually, during a 45 minutes interview, complete this O(m*n) method is enough. So, understanding what the point the interviewer asks is very important.

Think it in this way. If I were the interview:
This guy may be my potential colleague. Is there any bug here? Because if there are many bugs, I will probably debug a lot for him when we are in a team.
Is he talktive? Well, I will give you limited conditions about the problem and I hope you can ask me for more details. Also, to every question, pay attention to the boundry condition.

When we solve a coding problem

  1. Pay attention to the boundry condition
  2. Do communication during the writing part
  3. When finished coding, do a test case no matter the interviewer request or not

Permutations Problems

Subsets:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class Solution {
public ArrayList<ArrayList<Integer>> subsets(int[] S) {
ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> subset = new ArrayList<Integer>();
Arrays.sort(S);
helper(result, subset, 0, S);
return result;
}

private void helper(ArrayList<ArrayList<Integer>> result, ArrayList<Integer> subset, int len, int[] S) {
result.add(new ArrayList<Integer>(subset));
for(int i = len; i < S.length; i++) {
subset.add(S[i]);
helper(result, subset,i + 1, S);
subset.remove(subset.size() - 1);
}
}
}

Similar Problems:
SubsetsII
Permutations
PermutationsII
CombinationSum
Letter Combination of a Phone Number
Palindrome Partitioning
Restore IP address

Read More

This template is used for later markdown reference.

Fonts:

1
2
3
4
5
*Italics*
**Bold**
***Italics and Bold***
~~Scratch~~
It also works if you change the star(*) into underline(_).

Italics, Bold, Italics and Bold, Scratch

1
[My Website](http://kidchen.github.io/)

My Website

Reference:

Add “>“ before a line to express reference (add more “>“ to do nest).

This is a reference.

This is a nested reference.

Quote:

Say something.

[Author AAuthor B] [link] [source_link_title]

For more information, visit this page.

Different subtitles:

Add one to six sharps(#) and a space before the head.

Head1

Head2

Head3

Head4

Head5
Head6

Codes:

Use “`“ around the inline code or use “```“ to define coding area.

This is an inline code.

[title] [url] [link text]
1
code snippet
1
$ hexo new "My New Post"

List:

Use “*“, “+“ or “-“ followed with a space to express unordered list.

  • unordered list
  • nested unordered list
  • nested unordered list
  • nested unordered list
  • nested unordered list

Use numbers followed with a dot and a space to express ordered list.

  1. ordered list
  2. ordered list
  3. ordered list

Insert img:

1
![text](/path/to/your/img.jpg "option-title")

Miscellaneous:

Use three or more “*“, “-“ or “_“ to add divide line.
Note: There is no other characters in the divide line except spaces

Use “\“ as the escape character.

Use <!-- more --> to add “more” button.

A very nice Cheat Sheet for Markdown syntax.

Read More

身在异国的第二个生日,也是自己本命年的日子,总觉得应该说些什么,但又没什么好讲的。

如果说去年的生日,主题是放肆,那今年的一定就是平淡了。跟mm和xs三个人出去吃饭打牌看电影,一句话说完了,仅此而已。

毕业以后,自己从开始的浮躁,中途一度的紧张,到后来的释怀,慢慢沉淀了,不是经历上阅历上的沉淀,而是心态上的。说是成熟吧,也不算,但我和我的朋友们都渐渐地、谁都没有说出来但是大家却感觉得到地变稳重了。曾经的疯狂、无忌、逗比,都要越来越少,说不来是不是习惯,但想想还是一种遗憾。

还没收到epic的offer,心里多少还是忐忑,不过已经不顾一切的开始规划十二月的旅程和一月份展开的崭新的生活了。很多死党好友都将不在身边,老爸说在麦屯也能交到这样的好友,我不太肯定,从小到大每一段时光都很幸运能交到挚友,然而社会工作以后一定是另一番风景,心底一直有个念头一定要回加州,回硅谷,回到这群朋友身边。既然错过了,没办法一步到位,就只好曲折一点、麻烦一点、再辛苦一点,赶上大家的步伐。跟家人朋友也聊过,自己这十几年的求学生涯,大半时间都是在追赶别人,习惯了以他人为榜样,让自己变得更好,从来没有那种让优秀成为一种习惯的感觉。这样的情况的确让人不断进步,但也让我迷茫,现在偶尔会有困惑,困惑这种状况什么时候才到头,自己这么一直往上爬究竟想要什么,虽然更高的通常更好但真的更适合自己吗?

老生常谈,要不要回国,出国的意义在哪里。一年多来,我也不知道答案,的确会在某一刻反思自己何苦做这些经历这些,但更多的时候还是庆幸自己当初的选择,无所谓对与错,但这条路我决心走定了。24岁,是时候收拾起那些无谓的稚嫩和不痛不痒的疑惑,迈入人生的另一段旅程,或许难以适应,或许孤独无助,但已经走过那么多蜿蜒的路,这一趟为什么不行。

写在新生活之前,愿自己过得开心。

朋友们都不在身边了,喜欢热闹的人,有时不得不学会安静的一个人,慢慢思考,慢慢成长。6月2号到7月27号(暂定),56个日子,写下自己是如何度过的,毕竟,也是对自己意义不凡的一段时光。

GitHub(InterviewPreparation)

6.2: 开始刷题啦,兴奋起来!

6.3: 刷完前120题,要花两天时间按类型整理下才行啊,DP总是想不到,还有系列问题要系统的再过一遍才行。

6.4: 想起来记录的时候,leetcode已经39题了,以为一天可以刷十题,但是自制力为零的我怎么可能做得到,每天做完一题就要玩点别的。杨旸说我还要不要找工作了呀,唉,是该紧张起来了才对。

6.5: 跟老马一起刷题压力好大。

6.6: 今天效率还不错哦,终于一天刷两位数题目了,顺便投了bb和g家以及ccnet上几个小公司,还阴差阳错的约了一家公司下周一(6.9)的writing test。保持这个节奏,这周结束要刷过一半!

6.7: 感觉渐渐有点手感了,有些题有后续,在做后续时看看前面的题,很快能想起来,说明还是有效果,积累经验吧。

6.8: 果然周期来了,这两天效率都不高啊,晚上跟郝大厨聊天聊了很久,也没怎么刷题了,一半的目标看来是要靠过两天来弥补了。

6.9: 今天中午做了mercury的笔试,然后一小时后就收到说安排第二轮电面了,好诡异。安排到了周五下午,随意吧,反正八成也不去。另外被bb秒据了,难道是我没换邮箱的缘故吗?总之又投了slb,hp,citi,avaya,yodle。还是有面试的压力刷题快,嗯。

Read More

// 本文逼格颇高,熟人请慎入
// 说我逗比的,快command+w
// 最后一次机会了,小心眼瞎

怎么说起。
以为一年的生活,不会给我什么感情,但真的到了这天,却格外泛滥。
去年八月来到康村,新鲜,明媚,好奇着当前,期待着未来。那个张晨没有烦恼,没有压力。转眼一年过去,许多事情摆在眼前,现在的我已经不再去回忆,不是不愿,而是不敢。
这一年经历太多,学会很多也放弃很多,明白了一些事,认识了一些人。庆幸的是有ECE的小伙伴们一直和我在一起,屌丝楼也吃得很嗨,赶due也不再艰难。有爱的室友和CIPA的姑娘们,感谢一路的陪伴,在我心里总有你们的位置。还有机缘巧合或是阴差阳错认识的朋友们,我珍惜每一个你,相识本来就是一种命中注定。
暑假来临,是时候各奔东西,人们说无论在哪里,有缘都会相聚。我信。
康村的五月太美,还好我遇见你。

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×