由买买提看人间百态

topics

全部话题 - 话题: interger
首页 上页 1 2 3 下页 末页 (共3页)
b*******e
发帖数: 217
1
来自主题: JobHunting版 - find the first missing positive integer.
build a min-heap in o(n).
query the min element.
query the two child ot he min element.
if the three elements not consecutive. find the missing interger already.
Otherwiese, go to the smaller child until the missing integer is found. o(
logn)
complexity = o(n) + o(logn)
b*******e
发帖数: 217
2
来自主题: JobHunting版 - find the first missing positive integer.
build a min-heap in o(n).
query the min element.
query the two child ot he min element.
if the three elements not consecutive. find the missing interger already.
Otherwiese, go to the smaller child until the missing integer is found. o(
logn)
complexity = o(n) + o(logn)
E*******0
发帖数: 465
3
来自主题: JobHunting版 - Amazon店面第一轮
刚收到据信。
我因为太紧张了,之前只准备了1天,那个recruiter直接给我打电话,我开始以为是我
联系的其他的事情。然后和我说,给我明天安排一个technical phone interview.我说
能不能晚点,他说不行,他们有很多的candidate.我就同意了。
我总共就复习了12个小时,因为我白天没有时间,只有晚上的时间。
问题1:给我一个4byte的interger,把所有的bit都reverse一下。直接编程。
我当时理解错了题目,以为把digit reverse.浪费了不少时间。
问题2:给我一个数组,找到one pair 等于一个sum.
问我遇到过没有,我说,遇到过。
问题3:给我一个binary tree. 找到一个path from root to a leaf. Sum of the
path equal to the input sum.
问我遇到过没有,我说,没有。
直接写code,开始写的不好,没有思路。后来加了10分钟写完了code。感觉,应该没有
问题。
w**z
发帖数: 8232
4
来自主题: JobHunting版 - good way to solve this problem?
sequence defined for positive interger
n-> n/2 (n is even)
n-> 3n + 1 (n is odd)
starting from 13, we have
13, 40, 20, 10, 5, 16, 8, 4, 2, 1
which number under 1million, produces the longest chain.
n*******w
发帖数: 687
5
来自主题: JobHunting版 - 几年前G家onsite的一道题
如果用数字array的话,直接integer array就行吧。
考虑到要二进制打印,使用65536进制,每个数组元素表示一个"digit"。(假设
interger是16位)
w***g
发帖数: 5958
6
1B 32-bit interger也就4G, 怎么读都差不多, 应该能一次读进来。建议用fread,最
portable。
s******y
发帖数: 72
7
来自主题: JobHunting版 - VMware 面经顺求bless
Phone Interview:
research + coding,
Coding: String Match strstr(); naive way and KMP, write code
Onsite:
一共见了八个人,六个Enginneers, 两个senior manager,给了一个talk。
问了很多research和system相关的问题,以及coding, 记得的问题有
Coding and Language questions:
1) Given a interger array, find a consective subarray with maximal sum
2) 3Sum, without extra space. How to extend to handle KSum?
3) Write a thread safe queue
4) Editing distance, return minimal distance and the operations (remove,
insert, replace) to convert one strin... 阅读全帖
s******y
发帖数: 72
8
来自主题: JobHunting版 - VMware 面经顺求bless
Phone Interview:
research + coding,
Coding: String Match strstr(); naive way and KMP, write code
Onsite:
一共见了八个人,六个Enginneers, 两个senior manager,给了一个talk。
问了很多research和system相关的问题,以及coding, 记得的问题有
Coding and Language questions:
1) Given a interger array, find a consective subarray with maximal sum
2) 3Sum, without extra space. How to extend to handle KSum?
3) Write a thread safe queue
4) Editing distance, return minimal distance and the operations (remove,
insert, replace) to convert one strin... 阅读全帖
b*******e
发帖数: 217
9
来自主题: JobHunting版 - phone interview question
give a polynomial complexity algorithm to find whether a set of intergers
can be evenly divided into 3 subsets. that is: if sum of the set is A,
decide whether it can be divided into 3 subsets, each with sum = A/3.
c**c
发帖数: 74
10
来自主题: JobHunting版 - 算法面试题
面试题,感觉是下面believeme 的升级版。
give a polynomial complexity algorithm to find whether a set of intergers
can be evenly divided into 3 subsets. that is: if sum of the set is A,
decide whether it can be divided into 3 subsets, each with sum = A/3.
大意是,
两组整数A,B,没有排序, 长度分别为m,n,A中数是体积,B中数是容积大小
比如将A,B排序后,得到 比如 A= {17,16,16,13,12,7,4,3,2,1}
B={27,23,19,17,4,2,1}
A 中有17,4,3,1, B有27。那么,
27=17
27=17+4+3
27=17+4+3+1
把A中的数往B中放, 有什么方法能让放入B的数尽可能balance, A中的数如果放不到B
中可以不放。
有什么解法?
NP-complete,又近似的优化解法吗
c*****a
发帖数: 808
11
来自主题: JobHunting版 - 问游戏公司PG 两道题
第一题好像可以用dfs测试每个interger + - * / 的combination,不过好像是n!
H********e
发帖数: 130
12
来自主题: JobHunting版 - Epic Offer, 该不该从, 贴一些面经
面经:
Autodesk Interview(Failed)
Phone 1: java foundations
Phone 2: product manager, research, java foundation, composition vs
inheritance. find time interval
Phone 3: test my javascript background
Bloomberg Phone interview(failed)
C++ basics.
(Selection Algorithm)find kth element in array
ZEFR:
Contacted by HR, given a 60 min online test: finished only 8 out of 14
questions, failed.
Epic:
Phone1: Ask about background, previous project, introduce for epic, Q/A, etc
Assesment:
20 math;
Intro new pr... 阅读全帖
l**********9
发帖数: 537
13
来自主题: JobHunting版 - 问个题目,找不在区间内的所有数
有人做过这个题没有: 2个排序数组,数组1的元素是integer range, 例如 2-4, 5-9
。。。有start integer number,end interger number2个fields,按照先start
number排序,再end number排序,每个元素就是一个range。 第二个数组是integer
。 2个都是升序。 问找出第二个数组里面不在第一个数组所有range的所有元素
s*****b
发帖数: 8
14
来自主题: JobHunting版 - 请问除了刷题还能怎样提高编程
我来贴一个。
Rocket fule (Software Engineer - Machine Learning Scientist ) 技术电面后code
test. code通过了所有test cases. 人家看过code 后就拒了。问题在哪里呢?请各位
牛人不吝赐教。题目本版以前贴过
You are standing in a rectangular room and are about to fire a laser toward
the east wall. Inside the room a certain number of prisms have been placed.
They will alter the direction of the laser beam if it hits them. There
are north-facing, east-facing, west-facing, and south-facing prisms. If the
laser beam strikes an east-facing prism, its cours... 阅读全帖
s*w
发帖数: 729
15
来自主题: JobHunting版 - Google phone interview 金天
这题貌似就是考如何不用 / 实现 /
leetcode 有  divide two intergers 啊
没记错的话,就是使劲左移除数然后相减,得到结果再使劲左移再相减,结果就是所有
2^(左移的位数)相加
cc150 上有不用 +-做 +- 的:
做+: A+B = recursive +(A xor B, carry)
-: A+-B
-B : nagation +1
忘记咋做 * 了,难道是用左移相加?

where
f*****2
发帖数: 141
16
来自主题: JobHunting版 - 请教一道产生随机数的问题
这K个intergers应该是已知的吧?那这样可不可以?
int generate(int *kList, int K, int N)
{
int num;
gen:
num = rand()*N;
for (int i = 0; i < K, i++)
{
if num == kList[i];
goto gen;
}
return num;
}

which
a********9
发帖数: 129
17
来自主题: JobHunting版 - facebook面经
已挂
电面 1
国人大哥,应该有点放水
1) fabanacia,期待o(lgn)解法,但O(n)也行
2) generate all possible paretheses, leetcode原题,会让分析最优/平均时间,我
只知道worse case 是O(n^2)
onsite1
behavior: 1)有什么跟同事意见冲突的案例,怎么解决
2) 以前做过的项目如果现在再做会有什么不同/改进
3)divide and mod,但不能用/或者%,基本也是leetcode原题了
onsite2
system desgin: 因为我是kernel背景,让我用mutex,cv实现一个semephor,说先考虑
单核,然后拓展到多核,但我只写了单核的就没时间了,不知道多核的会有什么不同,
要求code compilable,MD三哥从一进来就没好脸色,此轮negative
onsite3:
1) 给你10g文件,1g内存,数总共有多少个不同的数,答案是用bit来记录数字,总共
4b个interger,最多用0.5gb来记录,follow up是如果只有400m怎么办,答案是把数字
hash... 阅读全帖
a********9
发帖数: 129
18
来自主题: JobHunting版 - facebook面经
已挂
电面 1
国人大哥,应该有点放水
1) fabanacia,期待o(lgn)解法,但O(n)也行
2) generate all possible paretheses, leetcode原题,会让分析最优/平均时间,我
只知道worse case 是O(n^2)
onsite1
behavior: 1)有什么跟同事意见冲突的案例,怎么解决
2) 以前做过的项目如果现在再做会有什么不同/改进
3)divide and mod,但不能用/或者%,基本也是leetcode原题了
onsite2
system desgin: 因为我是kernel背景,让我用mutex,cv实现一个semephor,说先考虑
单核,然后拓展到多核,但我只写了单核的就没时间了,不知道多核的会有什么不同,
要求code compilable,MD三哥从一进来就没好脸色,此轮negative
onsite3:
1) 给你10g文件,1g内存,数总共有多少个不同的数,答案是用bit来记录数字,总共
4b个interger,最多用0.5gb来记录,follow up是如果只有400m怎么办,答案是把数字
hash... 阅读全帖
P****d
发帖数: 137
19
最近骑驴找马在跳槽,工作了1年多一点,
最近差不多面了一轮第一轮电面
有些直接进ONSTE了,有些等第二轮电面, onsite都还没Schedule来着
应该就只面这些公司了,之后可能还会面一个GROUPON, EBAY和SALESFORCE,其他公司
不打算面了。
求祝福,求保佑ONSITE顺利啊,希望能有好OFFER
1.F
rain trap problem from leet code
在等schedule第二轮电面
2. Zuilily
实现一个open hash的hashmap
进了onsite
3. Walmart lab
reverse int,
还有一个多线程题目,不会做
也进了onsite
4.Google
Unique path from CC 150
search in rotate array from CC150
进了onsite
5.Twitter
求一个矩阵的最大子矩阵和,CC150上的题
在等SCHEDULE第二轮电面
6.Linkedin
LEVEL ORDER TRAVERSE TREE
给一个叫做NestedInteger的CLASS的LIST,... 阅读全帖
d*******8
发帖数: 23
20
来自主题: JobHunting版 - 这道FB题如何解?
I am not sure whether my analysis below is correct:
We have 2^42 messages. Each message has a unique ID, which is a 8B interger.
Assume each message has 8 words on average, and there are 2^14 unique words.
So each word appears in roughly 2^42 * 8 / 2^14 = 2^31 messages.
So in the index table, each word has roughly 2^31 corresponding records and
each record is a message ID (8B size). So the size of the index of each word
is 2^34B = 4GB.
Since there are 2^14 unique words, the total size of the ind... 阅读全帖
b******i
发帖数: 914
21
来自主题: JobHunting版 - Google onsite一题
自己贴个code,test过几个好像是对的:
string number_division(int a, int b) {
int q, r;
string result;
// interger part
q = a / b;
r = a - b * q;
result.append(to_string(q));
// digital part
unordered_map m;
string digits;
int idx = 0;
while(r > 0) {
a = r * 10;
q = a / b;
r = a - b * q;
if(m.find(a) == m.end()) {
m[a] = idx;
digits.push_back(q + '0');
idx++;
} else {
int... 阅读全帖
j*****8
发帖数: 3635
22
来自主题: JobHunting版 - 贡献一个 一个L家的店面题目
用一个interger保存当前的size,然后生成一个random position remove就行
不过你说得对,需要另外一个map存 。。
j*****8
发帖数: 3635
23
来自主题: JobHunting版 - 贡献一个 一个L家的店面题目
用一个interger保存当前的size,然后生成一个random position remove就行
不过你说得对,需要另外一个map存 。。
j***k
发帖数: 2719
24
来自主题: Living版 - 关于先前屋主有加建的问题
this is not a responsible suggestion.
True, bank does not care about the country business. But bank generally checks because they would be taken on a big risk should the county ever askes the owner to tear down the addition, especially if the addition is a part of the main house. The same reason the bank would require you to buy property insurance. They wanna to protect them from any element that could lower the value of their mortgage collateral.
Even if the bank omits the check, buying a hous... 阅读全帖
z*****s
发帖数: 131
25
in mobile system,.not all the RFIC is intergated with BB.
at least, PA is seperated.

like
B*D
发帖数: 5016
26
来自主题: StartUp版 - merchant account比较
我觉得估计啥merchant provider,都能g出一对负面的
其实基于intergate exchange +0.xx%的报价方式,应该更加清晰明朗一些
t******g
发帖数: 462
27
来自主题: Stock版 - let's pump DF!
kao, 赶2小时火车才到家,你不能让人把碗饭吃完?不是高手,周末没事随便聊聊。
华尔街是编故事,讲故事,听故事的地方。各种故事里最重要的一个情节是growth,传
说中持续稳定的增长,这就是垃圾NFLX,CMG炒得满天飞的原因。新兴公司最容易有增长
,达到一定规模后就要靠买其他同行来增加revenue/growth,再下去就要靠合并上游下
游公司merge/acquisition来grow,叫vertical intergation, 华尔街通常认为合并后
的公司更值钱,多出来的部分叫Synergy。M&G是给华尔街送钱,当然要给面子。公司之
间也不是随便乱买,一般都请华尔街公司做consulting,帮忙编故事:除了虚无的
synergy之外,要么增加growth,要么账面变好看, better balance sheet。早年把非
特这么做,2000年csco这么做,最近orcl在这么干。
以下故事只是大概情节,请勿追究细节
07年时,dean foods既有hugh cashflow, positive growth and low leverage,就好
像一个美女有貌 (g... 阅读全帖
a*****g
发帖数: 1320
28
ONE MORE: HOW MANY FIVE DIGIT INTERGERS ARE PERFECT SQUARE?

PROBABILITY
p**2
发帖数: 613
29
来自主题: LosAngeles版 - 今天大开杀戒
拍死1个PM,1个se,
本来只拍死一个se,警告pm
但是pm还狡辩,企图脏水泼我身上
直接拍死。
原因,那pm带的se,
第三方api没intergation好
导致3个月某个部分没数据,高层震怒(哈哈)
昨天来问我原因,我查完之后,
发现中间有个东西se覆盖错了。
结果pm就开始推卸责任。
对上面交代,
说我说了,是vendor没写清楚导致的。。
把注意力往我这里引。
去你妈的,老子直接把事情写出来给上面了
他他妈的还狡辩,说vendor没说清楚怎么做。。
我们我们的。。。
老子直接说,
首先,不是我们,是你们!
其次,vendor没说清楚是因为vendor认为你们是skilled
不需要解释那么简单的东西。
就算不对,也只有20%的责任。
你们搞不清楚,就应该问
你们也不问,你们至少有80%的责任!
现在pm和se死在沙滩上。。。
a*****g
发帖数: 1320
30
来自主题: SanFrancisco版 - 一道 中学数学题求助
麻烦给出解题过程, 谢谢了。
THE PRODUCT OF THE DIGITS OF 3214 IS 24. HOW MANY DISTINCT FOUR-DIGIT
POSITIVE INTEGERS ARE SUCH THAT THE PRODUCT OF THEIR DIGITS EQUALS 12? (TWO
EXAMPLES TO INCLUDE ARE 1126, 6112)
A. 33 INTEGERS B. 34 INTEGERS C. 35 INTEGERS D.36 INTERGERS.
a*****g
发帖数: 1320
31
来自主题: SanFrancisco版 - 中学数学题求教 --Thanks a lot!!
ONE MORE: HOW MANY FIVE DIGIT INTERGERS ARE PERFECT SQUARE?

PROBABILITY
a*****g
发帖数: 1320
32
来自主题: Seattle版 - 一道 中学数学题求助 (转载)
【 以下文字转载自 SanFrancisco 讨论区 】
发信人: ashuang (不要迷恋哥,哥只是个传说), 信区: SanFrancisco
标 题: 一道 中学数学题求助
发信站: BBS 未名空间站 (Sun Nov 7 12:42:22 2010, 美东)
麻烦给出解题过程, 谢谢了。
THE PRODUCT OF THE DIGITS OF 3214 IS 24. HOW MANY DISTINCT FOUR-DIGIT
POSITIVE INTEGERS ARE SUCH THAT THE PRODUCT OF THEIR DIGITS EQUALS 12? (TWO
EXAMPLES TO INCLUDE ARE 1126, 6112)
A. 33 INTEGERS B. 34 INTEGERS C. 35 INTEGERS D.36 INTERGERS.
a*****g
发帖数: 1320
33
ONE MORE: HOW MANY FIVE DIGIT INTERGERS ARE PERFECT SQUARE?

PROBABILITY
s****d
发帖数: 28
34
来自主题: BrainTeaser版 - 凸多边形.
应该可以作出sqrt(n) for any interger n的线段
a*****g
发帖数: 1320
35
【 以下文字转载自 SanFrancisco 讨论区 】
发信人: ashuang (不要迷恋哥,哥只是个传说), 信区: SanFrancisco
标 题: 一道 中学数学题求助
发信站: BBS 未名空间站 (Sun Nov 7 12:42:22 2010, 美东)
麻烦给出解题过程, 谢谢了。
THE PRODUCT OF THE DIGITS OF 3214 IS 24. HOW MANY DISTINCT FOUR-DIGIT
POSITIVE INTEGERS ARE SUCH THAT THE PRODUCT OF THEIR DIGITS EQUALS 12? (TWO
EXAMPLES TO INCLUDE ARE 1126, 6112)
A. 33 INTEGERS B. 34 INTEGERS C. 35 INTEGERS D.36 INTERGERS.
a*****g
发帖数: 1320
36
ONE MORE: HOW MANY FIVE DIGIT INTERGERS ARE PERFECT SQUARE?

PROBABILITY
y****9
发帖数: 144
37
来自主题: Database版 - SQL Server - how to obtain data type name
the cursor returned by using sp_describe_cursor_columns has a column called:
data_type_sql which is smallint type?
How can I obtain the data type name (like: varchar2 int etc) from data_type
_sql intergers?
I guess there should be a way to do, like from object_id to get object_name.
Thanks!
g****y
发帖数: 212
38
来自主题: DotNet版 - VB.Net question
In Class A, I have several private data memebers,
in one public function of A, I take another object B of type A as parameter.
Why can I access B's private member?
For example
public class A
private a1 as Integer
private b1 as Interger
public sub test(byval B as A)
me.a1 = B.a1
~~~~~~
end sub
End class
G**T
发帖数: 388
39
来自主题: DotNet版 - how to use old DLL in VB .NET?

your
got a solution: change all 'Long' to 'Interge'.
then it works!!!!!!!!!!!!!
but I do not know why. weird. maybe just a bug.
hehe
should
compile
z****n
发帖数: 1514
40
来自主题: Hardware版 - HTPC耗电比想象中要低
What about the new Interl Intergated HD graphics in i3, i5? Is it comparable
to ION?
G*********a
发帖数: 1080
41
来自主题: Java版 - help: Double or BigDecimal
1.5. sorry, i did type something wrong above.
thank u very much for ur testing, i also found the problem of my previous
code was mainly due to 1/2 in java in an interger type 0, i should have used
0.5 instead.
h**o
发帖数: 548
42
来自主题: Programming版 - what does 0x1L << 9 mean?
I see. L means 64 bit long interger.
left shift 1 for 9 times is 512.
thanks
b***e
发帖数: 1419
43
来自主题: Programming版 - 算法求教
I believe this is NPC. Here is a reduction to Knapsack:
Given a Knapsack problem as follows:
An array A = {a1, ..., an}, where for each i, ai is a positive integer, find
a subset B of A such that sum(B) = v, where v is a positive interger.
Without
losing generality, we can assume v <= sum(A) / 2;
Let w = sum(A) - 2 * v.
Let A' = A union {w} union Z, where Z = {0, ..., 0} is a set that contains n
+1 0s.
Now if your problem can be solved effectively, then I apply that algorithm
on A' to find out
i***h
发帖数: 12655
44
来自主题: Programming版 - Re: amazon onsite interview question (转载)
【 以下文字转载自 JobHunting 讨论区 】
发信人: moneyprinter (MP), 信区: JobHunting
标 题: Re: amazon onsite interview question
发信站: BBS 未名空间站 (Wed Jul 16 16:14:21 2008)
还有两道简单题忘了说了。
1)有一个8×8的chess board,每个grid存一个数字,数字大小从左向右递增,从上向
下递增。如下:
7 13 24 35 42
8 31 42 53 67
9 41 58 69 81
10 54 59 70 85
13 66 70 80 100
给出一个数字N,判断它是否在这个表中,如果在,处于什么位置。
2)一个sorted infinite long integer array(可以有duplicate,可以有negative
integer)
1, 3, 5, 13, 13 ... N,K,K,K...K, K, K...
K是这个array的最大值,N的位置和大小不知道。给出一个interger X, 找出它是否处
在这个array中。
b***y
发帖数: 2799
45
来自主题: Programming版 - [合集] 问2个微软电话面试题目
☆─────────────────────────────────────☆
wmbyhh (wmbyhh) 于 (Thu Jul 17 15:39:03 2008) 提到:
1、Suppose there is an interger array of size N, the value of each
element ranges from 1 to N-1, so there are at least two elements have
the same value. Find the fastest algorithm to detect the first
repeated element.
2、 int (*a) [10];
a++;
What is the value of a after this?
a是个指向地址的指针?还是a就是个地址?
☆─────────────────────────────────────☆
repast (xebec) 于 (Thu Jul 17 15:46:04 2008) 提到:
这第一个问题,把
r*******y
发帖数: 1081
46
来自主题: Programming版 - c++ class definition
but the example below is not ok.
//1.cpp
int i;
int main(){
return 0;
}
//2.cpp
int i;
if I compile g++ -o 1 1.cpp 2.cpp, then I will get a
redfinition error? here int i is also an external linkage.
What is the difference between th definition of a class and
an interger here? thanks.
D*****r
发帖数: 6791
47
我也来抄写一遍:(擦,写了半个小时放弃了,又要判断是不是负数,又要判断上下界
,记不住interger的上下界macro,超出上下界还得返回errno,需要exit么?。面试挂
了。)
int atoi(const char *str) {
int i, result, t;
char* p;
if (!str) return 0;
i = 0;
result = 0;
t = 0;
p = str;
while (*p) {
t = (int)(p[i]-'0');
if (!isdigit(t)) return -1;
result = result * 10 + t;
}
}
h****r
发帖数: 2056
48
Assume,
long a = 32767;
long b = 4;
long c = 5;
we know the upper limit of long is 32768,
Linux can not recognize the following expression:
cout << a*b+c;
it will pass the compile, but can not output the correct
result.
How to represent the a*b+c correctly here?
Thanks.
j***y
发帖数: 87
49

Really? long is 64 bits.
you must have errors somewhere else.
首页 上页 1 2 3 下页 末页 (共3页)