由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 三道 Amazon Onsite Coding 题
相关主题
一个有向图问题今天电面又被老印黑了。。。。 (转载)
Efficient algorithms for finding number, help pleaseRe: 有娃有老公,但是却感觉自己什么都没有。 (转载)
underlying sort algorithm for SET in STL?请问这个面试题想考啥啊?
A STL sorting algorithm problem问个有关C++ map的问题
sort algorithm百度面试题,any idea?
问个图的问题请问有什么c++ algorithm and data structure 好的书吗?
做题了做题了,集合分组问题问一个基本问题
这个题目能否半小时完成coding?如何 randomize 一个sorted的文件 ?
相关话题的讨论汇总
话题: api话题: maze话题: bab话题: bca话题: head
进入Programming版参与讨论
1 (共1页)
w***h
发帖数: 415
1
1.Given ordered/sorted words with some unknown alphabet ordering, find and
return the ordered alphabets, for example, given {“abce”, “bbdf”, “cceg
”} your class/function will return: {a, b, c, d, e, f, g}
2.Design an API class for some Maze algorithms – imagine that the software
team has implemented Maze algorithms, the hardware team needs to call the
API that you designed to run a single robot in Maze (no need to worry about
multi-thread);
After you coded API, then code a simulation to test API
U********d
发帖数: 577
2
栈和递归?如果硬件送过来的数据是实时的话,比如探测到一堵墙啥的,blah blah。
a*******s
发帖数: 79
3
第一题可以用hash,只要26个表元就行,复杂度O(n)
第二题就是个图的遍历算法,DFS,stack实现比较简单,主要就是看看你API的定义能力
第三题是不是考格式调整?左对齐,右对齐和左右都对齐?我觉得这个不是太难,就是
计算子串在绘图空间里面的实际长度,注意切分字串时考虑远东语言等情况。
I******c
发帖数: 163
4
第一题怎么用hash解?能否详细解释一下?
我的想法是遍列一次所有的字符串,比较相邻的字符串。每一次比较可以得到一个表示
两个字符前后关系的信息。然后把这些信息合并起来。(我使用静态链表)
时间复杂度也是O(n).
g**e
发帖数: 6127
5
hash 26个字母,value=0。按单词字母顺序put,value++
完了以后按顺序输出所有value!=0的
你的方法为什么是O(n),我怎么觉得是O(n^2)

【在 I******c 的大作中提到】
: 第一题怎么用hash解?能否详细解释一下?
: 我的想法是遍列一次所有的字符串,比较相邻的字符串。每一次比较可以得到一个表示
: 两个字符前后关系的信息。然后把这些信息合并起来。(我使用静态链表)
: 时间复杂度也是O(n).

I******c
发帖数: 163
6
我的办法只需要遍历一遍,所以是O(n)
例如有三个字符串 bca bab abc aca
静态链表是
0 0 0 向前指针
0 0 0 向后指针
a b c
1 2 3 索引
首先比较bca bab, 可以得到 c>a
-1 0 1
3 0 -1
a b c head=3

然后比较bab abc, 可以得到 b>a
-1 1 2
2 3 -1
a b c head=3
然后比较abc aca, 可以得到 b>c
-1 3 1
3 -1 2
a b c head=2
所以结果就是bca
I******c
发帖数: 163
7
向前,向后指针搞反了
我的办法只需要遍历一遍,所以是O(n)
例如有三个字符串 bca bab abc aca
静态链表是
0 0 0 向后指针
0 0 0 向前指针
a b c
1 2 3 索引
首先比较bca bab, 可以得到 c>a
-1 0 1
3 0 -1
a b c head=3

然后比较bab abc, 可以得到 b>a
-1 1 2
2 3 -1
a b c head=3
然后比较abc aca, 可以得到 b>c
-1 3 1
3 -1 2
a b c head=2
所以结果就是bca
m*****k
发帖数: 1864
8
靠,估计去了就是写kindle app。哈哈
b********h
发帖数: 119
9
第一题难道不是topological sort?怎么可能是hash?

【在 a*******s 的大作中提到】
: 第一题可以用hash,只要26个表元就行,复杂度O(n)
: 第二题就是个图的遍历算法,DFS,stack实现比较简单,主要就是看看你API的定义能力
: 第三题是不是考格式调整?左对齐,右对齐和左右都对齐?我觉得这个不是太难,就是
: 计算子串在绘图空间里面的实际长度,注意切分字串时考虑远东语言等情况。

n******n
发帖数: 12088
10
"1" confusing. what is ordered/sorted words, the letter in the word is
sorted, and these words are also sorted?
"2" also unclear. what is "maze problem" being solved here, finding a path from entry to exit? what code did u write?

cceg
software
about
algorithms.

【在 w***h 的大作中提到】
: 1.Given ordered/sorted words with some unknown alphabet ordering, find and
: return the ordered alphabets, for example, given {“abce”, “bbdf”, “cceg
: ”} your class/function will return: {a, b, c, d, e, f, g}
: 2.Design an API class for some Maze algorithms – imagine that the software
: team has implemented Maze algorithms, the hardware team needs to call the
: API that you designed to run a single robot in Maze (no need to worry about
: multi-thread);
: After you coded API, then code a simulation to test API

相关主题
问个图的问题今天电面又被老印黑了。。。。 (转载)
做题了做题了,集合分组问题Re: 有娃有老公,但是却感觉自己什么都没有。 (转载)
这个题目能否半小时完成coding?请问这个面试题想考啥啊?
进入Programming版参与讨论
N***m
发帖数: 4460
11
题3是啥意思?

from entry to exit? what code did u write?

【在 n******n 的大作中提到】
: "1" confusing. what is ordered/sorted words, the letter in the word is
: sorted, and these words are also sorted?
: "2" also unclear. what is "maze problem" being solved here, finding a path from entry to exit? what code did u write?
:
: cceg
: software
: about
: algorithms.

G****A
发帖数: 4160
12
请问用这里用hash table和用bool words[26]比较,
哪个好?

【在 g**e 的大作中提到】
: hash 26个字母,value=0。按单词字母顺序put,value++
: 完了以后按顺序输出所有value!=0的
: 你的方法为什么是O(n),我怎么觉得是O(n^2)

G****A
发帖数: 4160
13
请问用这里用hash table和用bool words[26]比较,
哪个好?

【在 g**e 的大作中提到】
: hash 26个字母,value=0。按单词字母顺序put,value++
: 完了以后按顺序输出所有value!=0的
: 你的方法为什么是O(n),我怎么觉得是O(n^2)

t****t
发帖数: 6806
14
ask yourself this question: what kind of data structure is "bool words[26]"?

【在 G****A 的大作中提到】
: 请问用这里用hash table和用bool words[26]比较,
: 哪个好?

v****s
发帖数: 1112
15
isn't problem 1 using bit array?
w***h
发帖数: 415
16
1.Given ordered/sorted words with some unknown alphabet ordering, find and
return the ordered alphabets, for example, given {“abce”, “bbdf”, “cceg
”} your class/function will return: {a, b, c, d, e, f, g}
2.Design an API class for some Maze algorithms – imagine that the software
team has implemented Maze algorithms, the hardware team needs to call the
API that you designed to run a single robot in Maze (no need to worry about
multi-thread);
After you coded API, then code a simulation to test API with Maze algorithms.
写完了code都一直没明白面试官想考什么? 这题大伙给说说看
3.Design and code in C++ to justify a line of text string: (1) left, (2)
right and (3) full justified.
U********d
发帖数: 577
17
栈和递归?如果硬件送过来的数据是实时的话,比如探测到一堵墙啥的,blah blah。
a*******s
发帖数: 79
18
第一题可以用hash,只要26个表元就行,复杂度O(n)
第二题就是个图的遍历算法,DFS,stack实现比较简单,主要就是看看你API的定义能力
第三题是不是考格式调整?左对齐,右对齐和左右都对齐?我觉得这个不是太难,就是
计算子串在绘图空间里面的实际长度,注意切分字串时考虑远东语言等情况。
I******c
发帖数: 163
19
第一题怎么用hash解?能否详细解释一下?
我的想法是遍列一次所有的字符串,比较相邻的字符串。每一次比较可以得到一个表示
两个字符前后关系的信息。然后把这些信息合并起来。(我使用静态链表)
时间复杂度也是O(n).
g**e
发帖数: 6127
20
hash 26个字母,value=0。按单词字母顺序put,value++
完了以后按顺序输出所有value!=0的
你的方法为什么是O(n),我怎么觉得是O(n^2)

【在 I******c 的大作中提到】
: 第一题怎么用hash解?能否详细解释一下?
: 我的想法是遍列一次所有的字符串,比较相邻的字符串。每一次比较可以得到一个表示
: 两个字符前后关系的信息。然后把这些信息合并起来。(我使用静态链表)
: 时间复杂度也是O(n).

相关主题
问个有关C++ map的问题问一个基本问题
百度面试题,any idea?如何 randomize 一个sorted的文件 ?
请问有什么c++ algorithm and data structure 好的书吗?如何sort and merge n 个sorted linked list
进入Programming版参与讨论
I******c
发帖数: 163
21
我的办法只需要遍历一遍,所以是O(n)
例如有三个字符串 bca bab abc aca
静态链表是
0 0 0 向前指针
0 0 0 向后指针
a b c
1 2 3 索引
首先比较bca bab, 可以得到 c>a
-1 0 1
3 0 -1
a b c head=3

然后比较bab abc, 可以得到 b>a
-1 1 2
2 3 -1
a b c head=3
然后比较abc aca, 可以得到 b>c
-1 3 1
3 -1 2
a b c head=2
所以结果就是bca
I******c
发帖数: 163
22
向前,向后指针搞反了
我的办法只需要遍历一遍,所以是O(n)
例如有三个字符串 bca bab abc aca
静态链表是
0 0 0 向后指针
0 0 0 向前指针
a b c
1 2 3 索引
首先比较bca bab, 可以得到 c>a
-1 0 1
3 0 -1
a b c head=3

然后比较bab abc, 可以得到 b>a
-1 1 2
2 3 -1
a b c head=3
然后比较abc aca, 可以得到 b>c
-1 3 1
3 -1 2
a b c head=2
所以结果就是bca
m*****k
发帖数: 1864
23
靠,估计去了就是写kindle app。哈哈
b********h
发帖数: 119
24
第一题难道不是topological sort?怎么可能是hash?

【在 a*******s 的大作中提到】
: 第一题可以用hash,只要26个表元就行,复杂度O(n)
: 第二题就是个图的遍历算法,DFS,stack实现比较简单,主要就是看看你API的定义能力
: 第三题是不是考格式调整?左对齐,右对齐和左右都对齐?我觉得这个不是太难,就是
: 计算子串在绘图空间里面的实际长度,注意切分字串时考虑远东语言等情况。

n******n
发帖数: 12088
25
"1" confusing. what is ordered/sorted words, the letter in the word is
sorted, and these words are also sorted?
"2" also unclear. what is "maze problem" being solved here, finding a path from entry to exit? what code did u write?

cceg
software
about
algorithms.

【在 w***h 的大作中提到】
: 1.Given ordered/sorted words with some unknown alphabet ordering, find and
: return the ordered alphabets, for example, given {“abce”, “bbdf”, “cceg
: ”} your class/function will return: {a, b, c, d, e, f, g}
: 2.Design an API class for some Maze algorithms – imagine that the software
: team has implemented Maze algorithms, the hardware team needs to call the
: API that you designed to run a single robot in Maze (no need to worry about
: multi-thread);
: After you coded API, then code a simulation to test API with Maze algorithms.
: 写完了code都一直没明白面试官想考什么? 这题大伙给说说看
: 3.Design and code in C++ to justify a line of text string: (1) left, (2)

N***m
发帖数: 4460
26
题3是啥意思?

from entry to exit? what code did u write?

【在 n******n 的大作中提到】
: "1" confusing. what is ordered/sorted words, the letter in the word is
: sorted, and these words are also sorted?
: "2" also unclear. what is "maze problem" being solved here, finding a path from entry to exit? what code did u write?
:
: cceg
: software
: about
: algorithms.

G****A
发帖数: 4160
27
请问用这里用hash table和用bool words[26]比较,
哪个好?

【在 g**e 的大作中提到】
: hash 26个字母,value=0。按单词字母顺序put,value++
: 完了以后按顺序输出所有value!=0的
: 你的方法为什么是O(n),我怎么觉得是O(n^2)

G****A
发帖数: 4160
28
请问用这里用hash table和用bool words[26]比较,
哪个好?

【在 g**e 的大作中提到】
: hash 26个字母,value=0。按单词字母顺序put,value++
: 完了以后按顺序输出所有value!=0的
: 你的方法为什么是O(n),我怎么觉得是O(n^2)

t****t
发帖数: 6806
29
ask yourself this question: what kind of data structure is "bool words[26]"?

【在 G****A 的大作中提到】
: 请问用这里用hash table和用bool words[26]比较,
: 哪个好?

v****s
发帖数: 1112
30
isn't problem 1 using bit array?
相关主题
嵌入式系统用什么sorting算法比较好?Efficient algorithms for finding number, help please
Algorithms and Data Structures那本比较好呢?underlying sort algorithm for SET in STL?
一个有向图问题A STL sorting algorithm problem
进入Programming版参与讨论
l*****a
发帖数: 559
31
同意,topcoder里有原题。
onsite出这种题夸张了。
http://community.topcoder.com/stat?c=problem_statement&pm=11239

【在 b********h 的大作中提到】
: 第一题难道不是topological sort?怎么可能是hash?
1 (共1页)
进入Programming版参与讨论
相关主题
如何 randomize 一个sorted的文件 ?sort algorithm
如何sort and merge n 个sorted linked list问个图的问题
嵌入式系统用什么sorting算法比较好?做题了做题了,集合分组问题
Algorithms and Data Structures那本比较好呢?这个题目能否半小时完成coding?
一个有向图问题今天电面又被老印黑了。。。。 (转载)
Efficient algorithms for finding number, help pleaseRe: 有娃有老公,但是却感觉自己什么都没有。 (转载)
underlying sort algorithm for SET in STL?请问这个面试题想考啥啊?
A STL sorting algorithm problem问个有关C++ map的问题
相关话题的讨论汇总
话题: api话题: maze话题: bab话题: bca话题: head