Question:codility Lesson3 PermMissingElem
My answer:
def solution(A):
length = len(A)
return (1 + length + 1) * length / 2 - sum(A)
本文介绍了一个解决 Codility Lesson 3 中 PermMissingElem 问题的方法。通过计算等差数列求和公式与数组元素之和的差值来找到缺失的元素。
Question:codility Lesson3 PermMissingElem
My answer:
def solution(A):
length = len(A)
return (1 + length + 1) * length / 2 - sum(A)

被折叠的 条评论
为什么被折叠?