A*****e 发帖数: 26 | 1 two c++ positions
1. interviewer: one Korean guy
C++ basics: public, private, struct, etc. 秒掉
C++ : the member functions of map,list, vector, how to resize vector, how
to delete the middle element in a given list, time complexity。 Nothing
difficult for me. list in stl is actually doubly linked list, so remove one
member would take O(1) time, but the reviewer seemed to disagree. Ask is
there a size member available for list in STL. A: i think so. I: er..ok (
seems he did not know that)
Programming problem: given a vector, check if two elements inside it can add
to a given sum. 很简单,一次写完,还正在检查,对方貌似有点着急,说要run,结
果一次就run 通了。
而后,剩余大段时间,闲聊了一会儿。
两天后,recruiter通知,you failed。 莫名
2. C++ position.
First, two online assessments, passed.
Phone screen. A white guy over 40 (i guess).说你简历上写了C,问你几个C的问题
好了。。。呃。。那个年代科班的cs都是先学C的吧,C++用的特别多最近, C还是两年
前搞过的。。我说行吧。
a. int f(const char *)什么意思,怎么用。。easy
b. do you know any C library function has this signature?
太久没用,顿了几秒,strlen, 其实strlen returns size_t,不过对方表示接受
c. write a f, following the contract f(s1)=f(s2) iff strcmp(s1,s2)
第一反应 hash,md5-like function could do this job. 讨论了一会儿,对方表示
hash不行
然后想到字符串匹配的,用trie,对方表示不知道什么是trie, 简单解释了下,但是
总觉得trie takes only one argument. how this work?
讨论了一会儿,总觉得莫名其妙的题目,对方问which data structure in c++ uses
something like trie...想到map
但是,compare string, map cannot help.
确认下,can i use sth like strcmp inside? NO!
对方给出提示,how do you use one map among different calls of f.
明白了
what he wants is something like:
static map
for each call f(s1)
check if s1 in the map, if so return index
or insert, and return index.
聊的很不愉快,solution着实有点雷人。。我说我觉得 map里面还是得strcmp呀,对方
一直说存下去,然后lookup index就好了。。。然后就结束了, 肯定挂了
use string as key, map根本就效率很差的
而且为比较两个字符串,这么做。。。searching string (m length) in map takes O
(mlogn).
感觉有点脑筋急转弯, 一般函数设计里面不会这么干的,刚开始卡在这里了。因为从
来不觉得这个是个good practice,为了省个参数就搞个static map。。。觉得这种实
用的小函数,各个调用之间不应该有联系的呀。所以开始时候没想到 动物园开动物大
会大象没来 这茬子做法。。
刚开始面,手上有工作的人换工作不容易啊,没什么时间刷题。。攒人品,向大伙儿学习 | d****n 发帖数: 12461 | 2 我觉得年底招老人都是走形式。首先最后这三个月校招是最热的。其次市场上换工作的
牛人也不多,所有公司都差不多憋着春天拿bonus呢。人才市场不热的时候,招人的也
没有底气,特别是有些公司不同组竞争,如果这个组一个月能招到3个人,另一个组一
个都没招到,那会java不会c++的也可以凑数了。
另外说回来,如果你说你是老人,一到抠细节气场就输了。因为对方永远可以设套。如
果你把握主动一笔带过,联系到你做的项目上去,那对方就只有反过来琢磨的份了。
how
one
add
【在 A*****e 的大作中提到】 : two c++ positions : 1. interviewer: one Korean guy : C++ basics: public, private, struct, etc. 秒掉 : C++ : the member functions of map,list, vector, how to resize vector, how : to delete the middle element in a given list, time complexity。 Nothing : difficult for me. list in stl is actually doubly linked list, so remove one : member would take O(1) time, but the reviewer seemed to disagree. Ask is : there a size member available for list in STL. A: i think so. I: er..ok ( : seems he did not know that) : Programming problem: given a vector, check if two elements inside it can add
| M********0 发帖数: 1230 | 3 bloomberg的题都很偏啊
C/C++的题都非常扣细节
是不是应该多研究下三本effective的书 好像里面对C++的使用细节讲的很多
但不知道能不能cover他家的面试题 | s*****n 发帖数: 360 | 4 BB的题目好偏门啊
how
one
add
【在 A*****e 的大作中提到】 : two c++ positions : 1. interviewer: one Korean guy : C++ basics: public, private, struct, etc. 秒掉 : C++ : the member functions of map,list, vector, how to resize vector, how : to delete the middle element in a given list, time complexity。 Nothing : difficult for me. list in stl is actually doubly linked list, so remove one : member would take O(1) time, but the reviewer seemed to disagree. Ask is : there a size member available for list in STL. A: i think so. I: er..ok ( : seems he did not know that) : Programming problem: given a vector, check if two elements inside it can add
| k*****e 发帖数: 93 | 5 I guess for list,
First, you need to locate the element. The complexity is O(n).
And then you can erase. The complexity is O(1).
So unless you are given the iterator, the complexity should be O(n).
how
one
add
【在 A*****e 的大作中提到】 : two c++ positions : 1. interviewer: one Korean guy : C++ basics: public, private, struct, etc. 秒掉 : C++ : the member functions of map,list, vector, how to resize vector, how : to delete the middle element in a given list, time complexity。 Nothing : difficult for me. list in stl is actually doubly linked list, so remove one : member would take O(1) time, but the reviewer seemed to disagree. Ask is : there a size member available for list in STL. A: i think so. I: er..ok ( : seems he did not know that) : Programming problem: given a vector, check if two elements inside it can add
| k*****e 发帖数: 93 | 6 For the second question:
Programming problem: given a vector, check if two elements inside it can add
to a given value.
How did you do it?
A brute-force method is to check all kinds of combinations of two elements.
The complexity is O(n^2).
But if you first sort, it takes O(nlogn). Then for each element a[i], search
(value - a[i]) in a sorted array. It takes O(logn). So totally O(nlogn)
again. The whole complexity is O(nlogn).
how
one
add
【在 A*****e 的大作中提到】 : two c++ positions : 1. interviewer: one Korean guy : C++ basics: public, private, struct, etc. 秒掉 : C++ : the member functions of map,list, vector, how to resize vector, how : to delete the middle element in a given list, time complexity。 Nothing : difficult for me. list in stl is actually doubly linked list, so remove one : member would take O(1) time, but the reviewer seemed to disagree. Ask is : there a size member available for list in STL. A: i think so. I: er..ok ( : seems he did not know that) : Programming problem: given a vector, check if two elements inside it can add
|
|