l**********i 发帖数: 84 | 1 面了1小时15分,前几题感觉不错,结果被问到tcp vs udp的时候根本不知道是啥玩意
儿,估计是悲催了。哎,题目如下:
1.Can you talk a little about yourself first?
2.Why do you choose p?
3.Difference between linkedlist and array
4.In what condition do you use tree structure? How do you keep them balanced?
5.TCP protocol vs UDP protocol (have no idea)
6.How do you implement a hash table?
following up question:
Data structure; size; hashfunction; linkedlist vs hashtable in dealing with
collision
7.coding
print spiral matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of
the matrix in spiral order.
For example,
Given the following matrix:
[
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
]
You should return [1,2,3,6,9,8,7,4,5].
coding题目挺简单的,听完题马上想到思路。我先说了一下思路,对方说可以。然后让
我说说代码的结构。我不知道该怎么答,就码了几个变量并解释他们是干什么的。感觉
对方似乎不是很满意。在写代码的时候面试官总是让我停下来解释怎么回事。根本没时
间检查bug。最后我用个例子,放到代码里一行一行地解释怎么回事,讲了半天对方才
肯定我的code会work.讲完后我试探地说“i'm sure you probably have other
solutions", 面试官说是。
面完后搜了下才知道是leetcode上的题,面试官估计是有更优解。
-----------------------------
上spiral matrix的代码,请码友们多多批评指教~
//java
public void printSpiral(int[][] numbers) {
int direction =0;//if 0 go right, if 1 go down, if 2 go left, if 3 go up
int row=0, column=0;
while(numbers[row][column]!=Integer.MIN_VALUE){
System.out.print(numbers[row][column]);
numbers[row][column]=Integer.MIN_VALUE;
int nextrow=nextrow(direction, row);
int nextcolumn=nextcolumn(direction, column);
if (!isValid(numbers, nextrow, nextcolumn)) {
nextrow=nextrow(direction, row);
nextcolumn=nextcolumn(direction, column);
if (!isValid(numbers, nextrow, nextcolumn)) break;
}
row = nextrow;
column=nextcolumn;
}
}
int nextrow(int direction, int row){
if (direction==0){//moving left
return row;
}
else if (direction==1){//moving down
return row+1;
}
else if (direction==2){//moving right
return row;
}
else {//moving up
return row-1;
}
}
int nextcolumn(int direction, int column){
if (direction==0){//moving left
return column+1;
}
else if (direction==1){//moving down
return column;
}
else if (direction==2){//moving right
return column-1;
}
else {//moving up
return column;
}
}
boolean isValid(int [][]numbers, int nextrow, int nextcolumn){
return (nextrow<0||
nextrow>numbers.length-1||
nextcolumn<0||nextcolumn>numbers[0].length||
numbers[nextrow][nextcolumn]==Integer.MIN_VALUE)?false: true;
} | j*****n 发帖数: 1545 | | l**********i 发帖数: 84 | 3 半路出家,cs
【在 j*****n 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 你啥专业的?
| g**4 发帖数: 863 | 4 bless!
第5题introduction to computer networking里会讲到,不知道应该算正常
请问p是paypal吗?
balanced?
with
【在 l**********i 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 面了1小时15分,前几题感觉不错,结果被问到tcp vs udp的时候根本不知道是啥玩意 : 儿,估计是悲催了。哎,题目如下: : 1.Can you talk a little about yourself first? : 2.Why do you choose p? : 3.Difference between linkedlist and array : 4.In what condition do you use tree structure? How do you keep them balanced? : 5.TCP protocol vs UDP protocol (have no idea) : 6.How do you implement a hash table? : following up question: : Data structure; size; hashfunction; linkedlist vs hashtable in dealing with
| l**********i 发帖数: 84 | 5 恩是的。最近学networking已经知道了。多么痛的领悟啊
【在 g**4 的大作中提到】![](/moin_static193/solenoid/img/up.png) : bless! : 第5题introduction to computer networking里会讲到,不知道应该算正常 : 请问p是paypal吗? : : balanced? : with
| m********l 发帖数: 791 | 6 基本上udp/tcp 不了解的就是半路出家的了。。我也不了解 因为我也是半路出家 LOL
【在 l**********i 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 半路出家,cs
| l**********a 发帖数: 181 | |
|