首页 > b站测开笔试
头像
残月20190413215821
编辑于 2020-09-04 21:03
+ 关注

b站测开笔试

第一题twosum问题为啥我只能过28%
def find_children(candiesNeed, candies): # write code here  candies.sort()
    res = []
    left = 0  right = len(candies) - 1  while left < right:
        num = candies[left] + candies[right]
        low = candies[left]
        high = candies[right]   if num < candiesNeed:   while left < right and candies[left] == low:
                left += 1  elif num > candiesNeed:  while left < right and candies[right] == high:
                right -= 1  else:
            res.append([left,high])  while left < right and candies[left] == low:
                left += 1  while left < right and candies[right] == high:
                right -= 1  if res: return res[0]  else:  return [-1, -1]

全部评论

(2) 回帖
加载中...
话题 回帖

推荐话题

相关热帖

历年真题 真题热练榜 24小时
技术(软件)/信息技术类
查看全部

近期精华帖

热门推荐