提高警惕,谨防骗子!# Living
s*d
1 楼
没什么好说的,还是自己不行。
第一题
abstract class absClass
{
public int AddTwoNumbers(int Num1, int Num2)
{
return Num1 + Num2;
}
public abstract int MultiplyTwoNumbers(int Num1, int Num2);
}
实例化 absclass
interviewer 说 不需要用考到任何算法知识。只考java。
answer :
public class aaClass extends absClass {
public int MultiplyTwoNumbers(int Num1, int Num2){
int multiplyresult = 0 ;
multiplyresult=Num1*Num2;
return multiplyresult;
}
这个有什么问题?
Q2:经典题
Q2:
Given a sorted 2-D array (M x N) containing integers with the following
properties:
* All integers in any row are sorted left to right
* The first integer in any row is greater than the last integer in the
previous row
E.g.
1 3 5 7
10 11 16 20
23 30 34 50
我先说从last column search 再在row line search O(N+M);
interview说有better 方法。
我说可以用binary search。
他说combine both。 我就total lost了(我就没想出来怎么叫combine both)
死活想不出来 在m/2 n/2 开始binary search。
之后提出跟种方法。比如展开成1D 直接做binary search。得到否定答案。
说了用对角线 查找 也不是最优的。
interviewer 提示了说matrix 很大
谈论了半天不得要领。
直接先写程序,那时,心都凉了,紧张死了。后来连怎么算[][]size的搞错了。
哎。
肯定挂了。
讨论贴:
http://stackoverflow.com/questions/2457792/given-a-2d-array-sor
increasing-order-from-left-to-right-and-top-to-bottom
问个问题,在java 里2D是怎么放的? 如果实际上是1D存储的话。是不是用1D更快。
在讨论贴了好像O(logn))并不是比(n+M)更快。
谢谢
第一题
abstract class absClass
{
public int AddTwoNumbers(int Num1, int Num2)
{
return Num1 + Num2;
}
public abstract int MultiplyTwoNumbers(int Num1, int Num2);
}
实例化 absclass
interviewer 说 不需要用考到任何算法知识。只考java。
answer :
public class aaClass extends absClass {
public int MultiplyTwoNumbers(int Num1, int Num2){
int multiplyresult = 0 ;
multiplyresult=Num1*Num2;
return multiplyresult;
}
这个有什么问题?
Q2:经典题
Q2:
Given a sorted 2-D array (M x N) containing integers with the following
properties:
* All integers in any row are sorted left to right
* The first integer in any row is greater than the last integer in the
previous row
E.g.
1 3 5 7
10 11 16 20
23 30 34 50
我先说从last column search 再在row line search O(N+M);
interview说有better 方法。
我说可以用binary search。
他说combine both。 我就total lost了(我就没想出来怎么叫combine both)
死活想不出来 在m/2 n/2 开始binary search。
之后提出跟种方法。比如展开成1D 直接做binary search。得到否定答案。
说了用对角线 查找 也不是最优的。
interviewer 提示了说matrix 很大
谈论了半天不得要领。
直接先写程序,那时,心都凉了,紧张死了。后来连怎么算[][]size的搞错了。
哎。
肯定挂了。
讨论贴:
http://stackoverflow.com/questions/2457792/given-a-2d-array-sor
increasing-order-from-left-to-right-and-top-to-bottom
问个问题,在java 里2D是怎么放的? 如果实际上是1D存储的话。是不是用1D更快。
在讨论贴了好像O(logn))并不是比(n+M)更快。
谢谢