1. 程式人生 > >Google 面經

Google 面經

secret bool sim gpo memory any white align tor

1. 給你兩個string
if function(s1) == function(s2) return true
else return false. 1point3acres.com/bbs

function做的事情 遇到b 就刪除前面一個字元 其他就不管 當b太多的時候 return ""


for example
accc => accc
accb => ac
abdd => dd
. visit 1point3acres.com for more.
如果string 非常大
無法fit memory 怎麼辦
. 鐣欏鐢寵璁哄潧-涓€浜╀笁鍒嗗湴

答案:
用iterator 然後從後面開始讀

2. 給三個function
String hash(String s).
String encrypt(String message)
String decrypt(String secret)


eg.
encrypt("secret") = "12345"
decrypt("12345") = "secret"
要設計一個信息加密serve,其實是寫一個class 完成這兩個function
void sendMessage(String id, String message).
String getMessage(String id)


eg.
sendMessage(‘Bob‘, ‘Hi‘)
getMessage(‘Bob‘) // ‘Hi‘

3. Robot Clearner

Givena robot cleaner in a room modeled as a grid. Each cell in the grid can be emptyor blocked. The robot cleaner can move forward, turn left or turn right. Whenit tries to move into a blocked cell, its bumper sensor detects the obstacleand it stays on the current cell. Thecontrol API: interfaceRobot { //returns true if next cell is open and robot moves into the cell. //returns false if next cell is obstacle and robot stays on the current cell. booleanMove(); //Robot will stay on the same cell after calling Turn*. k indicates how //many turns to perform. voidTurnLeft(int k); voidTurnRight(int k); //Clean the current cell. voidClean();more. booleanMove(Direction d); }
Sampleinput ++++++++++ +........+ +...^....+ +.+......+ ++++.+++++ +.....+ +++++++

. 1point 3acres 璁哄

要求用定的API完所有empty格子。Timecomplexity, linear in term of room space.

Google 面經