面经------Google Onsite(2)

  1. 又是纯数学题. Black Jack.
    给你infinity张牌. Card value 1到10. Find the probability that a card will bust. P(bust|x=hand)
    玩家17 to 21时赢, 超过21 bust.
    答案:Leetcode 837

  2. 给你N幅画. 每幅画都有price和quality. 用最低价格买K幅画, with 0<K<=N
    Constraint: 买的画必须遵守minimum price for 那幅画. 用了一个ratio来买一幅画, 剩余的K-1幅画都要遵守这个ratio.
    答案:Leetcode Minimum Cost To Hire K Workers

  3. i. 给你一个tree. 里面多了一条edge, 所以不是binary tree了. Remove 那个多余的edge.
    ii. Implement power(x,y) st it returns x^y. Optimize 它
    答案:1.
    2.二分法解决,时间是O(logn)。

public double myPow(double x, int n) {
        if (n == 0)
			return 1;
		double res = myPow(x, n / 2);
		return n % 2 == 0 ? res * res : n < 0 ? res * res * (1 / x) : res * res * x;
    }
  1. i. 猜字游戏. 给你一个secret word, 一个guess word. Return <number of words that is guessed correctly and at correct position, number of words that is guessed correctly but at wrong position>
    ii. 迷宫. 给你一个有一些墙的迷宫. 怎么从start去到end.
    答案:Leetcode Guess the word

  2. 一个俄罗斯小哥, 人狠话不多.
    给你一个infinite size length array, 和list of queries in the format of <i,j>, find the maximum number from index i to index j in array.
    答案:区间树

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值