From 9cb75913e49ff27a6b4308751758262537574d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Thu, 29 Jun 2023 15:16:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=89=BE=E5=88=B0=E6=89=80=E6=9C=89?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E4=B8=AD=E6=B6=88=E5=A4=B1=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../day03/problem_solving_22.py" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "14_\345\210\267\351\242\230/day03/problem_solving_22.py" diff --git "a/14_\345\210\267\351\242\230/day03/problem_solving_22.py" "b/14_\345\210\267\351\242\230/day03/problem_solving_22.py" new file mode 100644 index 0000000..2a2aff9 --- /dev/null +++ "b/14_\345\210\267\351\242\230/day03/problem_solving_22.py" @@ -0,0 +1,15 @@ +""" +找到所有数组中消失的数字 +""" +from typing import List + + +class Solution: + def findDisappearedNumbers(self, nums: List[int]) -> List[int]: + all = set([i + 1 for i in range(len(nums))]) + return list(all.difference(set(nums))) + + +if __name__ == '__main__': + result = Solution().findDisappearedNumbers([4, 3, 2, 7, 8, 2, 3, 1]) + print(result) -- GitLab