楼主: melody_qyao
跳转到指定楼层
上一主题 下一主题
收起左侧

发一个yelp的skype电面面经,已跪

🔗
syftalent 2016-1-26 01:19:15 | 只看该作者
全局:
用 dfs 解?
class Solution{
        public boolean dartGame(int[] score, int target){
                return helper(new int[score.length], score, target);
        }

        private boolean helpeR(int[] mark, int[] score, int target){
                for(int i=0; i< mark.length; i++){
                        if(!mark[i] || target < score[i]){
                                continue;
                        }
                        if(target == score[i]){
                                return true;
                        }
                        mark[i] = true;
                        if(helper(mark, score, target - score[i])){
                                return true;
                        }else{
                                mark[i] = false;
                        }
                }
                return false;
        }
}
回复

使用道具 举报

🔗
u-r-the-one 2016-3-26 01:52:05 | 只看该作者
全局:
请问LZ你面的是哪一个组?
回复

使用道具 举报

🔗
bobzhang2004 2016-4-4 10:06:23 | 只看该作者
全局:
这不是类似dp的背包问题吗?
回复

使用道具 举报

全局:
请问楼主第一轮HR电话有问一些概念问题么?什么database join, ssl缩写啥的?
回复

使用道具 举报

🔗
鱼鱼 2016-4-6 07:09:03 | 只看该作者
全局:
楼主海投拿到面试,一定背景很强666
回复

使用道具 举报

🔗
yfcheng 2016-4-7 01:06:56 | 只看该作者
全局:
AndyLiu0429 发表于 2015-7-20 17:18
dp可以解决吧。。不排序的话就是没法去重了。

感觉不需要去重吧,最后求的是能否组成给定分数,如果可以组成的话,dp[k]最后一定是true吧
回复

使用道具 举报

🔗
yfcheng 2016-4-7 01:09:43 | 只看该作者
全局:
这个可以用经典的coin change方法,大概就是背包问题,楼主可以看下leetcode的coin change题
回复

使用道具 举报

🔗
qiu_cqupt 2016-10-18 08:28:22 | 只看该作者
全局:
  1. class Solution(object):
  2.     def dartGame(self, scores, target):
  3.         """
  4.         :type scores: List[int]
  5.         :rtype: Bool
  6.         """
  7.         scores.sort()
  8.         return self.dfs(scores, target)


  9.     def dfs(self, scores, target):
  10.         if target==0:
  11.             return True

  12.         if target<0 or not scores:
  13.             return False

  14.         for i in range(len(scores)):
  15.             if scores[i]<=target:
  16.                 if self.dfs(scores[i+1:], target-scores[i]):
  17.                     return True
  18.         return False


  19. scores = [3,5,3,3,5]
  20. target = 7
  21. so = Solution()
  22. a = so.dartGame(scores, target)
  23. print a
复制代码


there you go
回复

使用道具 举报

🔗
leros 2016-10-23 01:37:10 | 只看该作者
全局:
每次从n里面减去一个数,然后从list里面pop掉减去的这个数,重复上述过程直到n变成0。如果任何情况下都无法得到0, 返回False。时间复杂度exponential

  1. def valid_score(lst, n):
  2.     if n == 0:
  3.         return True

  4.     for i, num in enumerate(lst):
  5.         if valid_score(lst[:i] + lst[i+1:], n - num):
  6.             return True

  7.     return False
复制代码


评分

参与人数 2大米 +6 收起 理由
jszjlrl + 3 给你点个赞!
chengziwawa + 3 很有用的信息!

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表