Google 面经

1. 給你兩個string 
if function(s1) == function(s2)  return true
else return false1point3acres.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.

 

转载于:https://www.cnblogs.com/liangmou/p/8437922.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值