爱奇艺算法岗编程题ak【python版】
一直对爱奇艺还是比较向往的,内推没成功,笔试认真做了,编程题也ak了,希望能给个面试机会吧,当然如果能有offer就更好了啊【pia醒】
lst = input().split() N = int(lst[0]) M = int(lst[1]) P = int(lst[2]) foodlst = list(map(int, input().split())) for i in range(M): lst = input().split() if lst[0] == 'A': foodlst[int(lst[1]) - 1] += 1 else: foodlst[int(lst[1]) - 1] -= 1 b = foodlst[:] b.sort(reverse = True) print(str(b.index(foodlst[P-1]) + 1))
很幸运前几天刚看了左神的算法课,贪心策略,先结束的先安排
N = int(input()) noodles = [] for i in range(N): lst = input().split() a = int(lst[0]) b = int(lst[1]) if a < b: noodles += [[a,b]] else: noodles += [[b,a]] noodles.sort(key = lambda x:x[1]) cnt = 0 start = -1000 for n in noodles: if n[0] >= start: cnt += 1 start = n[1] print(cnt)
但是不知道为啥顺丰一样的题,一样的代码只能ac83%……
#爱奇艺##笔试题目#