题解 | 机器翻译

机器翻译

https://www.nowcoder.com/practice/45ecfecd83104f37a685016361be504c

m, n = map(int,input().split())
w = list(map(int,input().split()))
sm, ans = [], 0#栈,未命中次数
for c in w:
    if c not in sm:#未命中
        ans += 1
        if len(sm)>=m:#栈满了,首元素出栈
            sm.pop(0)
        sm.append(c)#未命中新元素入栈尾
print(ans)

全部评论

相关推荐

10-29 18:20
济南大学 Java
用微笑面对困难:他不是人事吗,怎么净特么不干人事
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务