码迷,mamicode.com
首页 > 其他好文 > 详细

google onsite 1

时间:2018-08-30 10:54:51      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:edm   first   https   data-   bst   EAP   span   over   alt   

  1. Given a 2D matrix , with obstacles. Start from any of the first row, exit from any of the last row. What is the minimum steps?

           

           000001

           000100

           000000

           000100

     step


 



2. Given a list of buslines, and the stops of each busline, given a start stop, and a end stop, what is the minimum number of transfers to reach the end stop from start stop

815. Bus Routes



busline1: A B C D E F H

busline2: G D H E I

start:B

end:I


List<Buslines1, List<Stops>>   start, end

  1. Find the start, List<Stops>

Map<Stop, Busline> invertedMap


busline1

                              / / / \ \ \ \

                           A B C D E F H

                                            \ \

                                            busline2

                                             / | \ \

invertedMap:  stop , list<buslines>














3. Given a table of candidates, each has a column of quality score, a minimum salary.


Candidates

QualityScore

MinimumSalary

A

1

1

B

5

20

C

25

20


Also,  if you want to hire A and B both, you must pay A at least 10/5 * 20 = 40 instead of 15.

What is the minimum salary you have to pay in total to hire them all?


follow up. if you only want to hire k out of n candidates, what is the minimum salary you have to pay?


A: 1 , 1, 1

B: 5, 20, 4

C: 25, 20, 0.8


A: 1 , 1

B: 5,20


maxHeap: (n-k)logn


B:4 => A:4



ratio sort  4 1 0.8

quality score:    1 5 25








N choose k


4. Given a box of fixed width and height in pixels, and two APIs getWidth(char c, font), getHeight(char c). Given a string “abc...hi”, what is the maximum font size can you use?



paper width, height

paper fix size


xxxxxxx

xxxxxxx

xxxxxxx


binary search

a

b

c

h

i


0,




5. given a list of subsequence of certain original array, recover the original array.

e.g.[1, 3, 5, 9]    

    [3, 4, 9]

    [4,5]

Then the original array is :  [1, 3, 4, 5, 9]

if no unique solution, return null


1 : 3 , 5, 9

3 : 5, 9, 4

5 : 9

4 : 9, 5


444. Sequence Reconstruction

技术分享图片
 
 
 
 
 
 
 
 

google onsite 1

标签:edm   first   https   data-   bst   EAP   span   over   alt   

原文地址:https://www.cnblogs.com/tobeabetterpig/p/9557880.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!