由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Amazon面试题请教
相关主题
问个google面试题彭博 面试题
google 面试题向各位大侠请教几道面试题的思路
请教一道面试题图的拷贝
问一个面试题问个google面试题
大家看一下这道google面试题问一个面试题
问个google面试题Course Schedule II 变形题怎么做?
Given an array of N integers from range [0, N] and one is missing. Find the missing number.Google电话面试题目
Find the node with given value in binary tree in in-orderGiven a node of a tree, find all nodes on the same level
相关话题的讨论汇总
话题: finds话题: array话题: between话题: given话题: time
进入JobHunting版参与讨论
1 (共1页)
j***n
发帖数: 301
1
Given an integer array A[], what preprocessing you need to do so that when g
iven i and j such that i <= j, you can tell in O(1) time the number of eleme
nts in the array having values between and including i and j.
A graph is given. You need to design a data structure with minimum space com
plexity such that it does the follows
--> Finds whether nodes u and v have a path in between them in O(1) time.
--> Finds whether there is a path of length l between u and v in O(k) time.
What does the follo
p******n
发帖数: 32
2
第一题直接把数组排序,另外用一个hash table记录每个value,e.g.,i,j在排序后数
组中的索
引。
r*d
发帖数: 896
3
程序是统计的n的二进制表示中1的个数。

g
eleme
com
time.

【在 j***n 的大作中提到】
: Given an integer array A[], what preprocessing you need to do so that when g
: iven i and j such that i <= j, you can tell in O(1) time the number of eleme
: nts in the array having values between and including i and j.
: A graph is given. You need to design a data structure with minimum space com
: plexity such that it does the follows
: --> Finds whether nodes u and v have a path in between them in O(1) time.
: --> Finds whether there is a path of length l between u and v in O(k) time.
: What does the follo

n*******s
发帖数: 482
4
(1) Using counting sort, the helper array C[]. C[x] is the number of
elements in original array that smaller than or equal to x. So the number in
range (i,j] should be C[j] - C[i]. If the range is [i,j] , just do a small
modification.
s*******s
发帖数: 46
5

g
eleme
先sort A[], 然后得到一个数组B[k],表示A[] 然后答案就是B[t2]-B[t1] (A[t1]=i, A[t2]=j)
com
time.
what is k?另外,第二个是否需要最短距离还是任意距离?
使用一个dp算法可以得到图中任意两点最短距离。
然后你可以使用linkedlist来表示这个sparse矩阵。

【在 j***n 的大作中提到】
: Given an integer array A[], what preprocessing you need to do so that when g
: iven i and j such that i <= j, you can tell in O(1) time the number of eleme
: nts in the array having values between and including i and j.
: A graph is given. You need to design a data structure with minimum space com
: plexity such that it does the follows
: --> Finds whether nodes u and v have a path in between them in O(1) time.
: --> Finds whether there is a path of length l between u and v in O(k) time.
: What does the follo

s*********t
发帖数: 1663
6
t1,t2是怎么出来的?如果二分查找已经不能O(1)了
i和j也未必是A里的数

【在 s*******s 的大作中提到】
:
: g
: eleme
: 先sort A[], 然后得到一个数组B[k],表示A[]: 然后答案就是B[t2]-B[t1] (A[t1]=i, A[t2]=j)
: com
: time.
: what is k?另外,第二个是否需要最短距离还是任意距离?
: 使用一个dp算法可以得到图中任意两点最短距离。
: 然后你可以使用linkedlist来表示这个sparse矩阵。

1 (共1页)
进入JobHunting版参与讨论
相关主题
Given a node of a tree, find all nodes on the same level大家看一下这道google面试题
divide array into two, sum of difference is min in O(N)问个google面试题
来做一个暴力题Given an array of N integers from range [0, N] and one is missing. Find the missing number.
Extension problem of finding intersection of two sorted arrayFind the node with given value in binary tree in in-order
问个google面试题彭博 面试题
google 面试题向各位大侠请教几道面试题的思路
请教一道面试题图的拷贝
问一个面试题问个google面试题
相关话题的讨论汇总
话题: finds话题: array话题: between话题: given话题: time