搜狐视频笔试

Posted ivyharding_wang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了搜狐视频笔试相关的知识,希望对你有一定的参考价值。

1. 统计数字:计算数字k在0到n中出现的次数,k可能是0-9的一个值

n=12,k=1,在[0,1,2,3,4,56,7,8,9,10,11,12],发现1出现了5次(1,10,11,12)

def countK(k,num):
    count = 0
    listK = list(range(num+1))
    for item in listK:
#         print("item = ",item)
        for i in str(item):
#             print("i = ",i)
            if i == str(k):
                count += 1
#                 print("count=",count)
    return count   

if __name__ == "__main__":
    k,num = map(int,input().split(" "))
    print(countK(k,num))

2.leetcode 754到达终点的数字

在一个无限长的数轴上,你站在0的位置,终点在target的位置,每次你可以选择向左或者向右移动。第n次移动(从1开始),可以走n步

返回到达终点需要的最小移动次数

target = 3,

输出:2

解释:第一次移动,从0-1

          第二次移动,从1-3

def move(target):
    s = 0
    i = 1
    while True:
        s += i
        if s>=target and (s-target)%2 == 0:
            return i
        i += 1

if __name__ == "__main__":
    target = int(input())
    print(move(target))

  

以上是关于搜狐视频笔试的主要内容,如果未能解决你的问题,请参考以下文章

2017搜狐畅游web笔试

搜狐_笔试_题目二

搜狐_笔试_题目一kolakoski序列

剑指Offer——当当+搜狐+好未来笔试题+知识点总结

仿爱奇艺视频,腾讯视频,搜狐视频首页推荐位轮播图介绍

一个仿爱奇艺视频,腾讯视频,搜狐视频首页推荐位轮播图类库