google onsite 1

Posted tobeabetterpig

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了google onsite 1相关的知识,希望对你有一定的参考价值。

  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的主要内容,如果未能解决你的问题,请参考以下文章

1Google Grpc 框架源码解析 之 Hello World

3.1 .1Google Tag Manager基础知识——GTM简介

google onsite Feb 13 2018.

XCode 十一大礼包 --2018 Google Onsite 面经最全总结

Amazon onsite

amazone onsite 1