Re: [闲聊] 每日LeetCode

楼主: sustainer123 (caster)   2024-01-22 15:31:12
※ 引述《JerryChungYC (JerryChung)》之铭言:
: https://leetcode.com/problems/set-mismatch
: 645. Set Mismatch
: 有一组1~n的整数set,但有一个数字重复与一个数字丢失了,找出重复与缺失的数回传。
: Example 1:
: Input: nums = [1,2,2,4]
: Output: [2,3]
: Example 2:
: Input: num = [1,1]
: Output: [1,2]
: 思路:
: 1. 做一个1~n组成的set,利用差集找出缺失的数
: 2. 用Counter找出出现2次的数
: Python3 code:
:
作者: SecondRun (雨夜琴声)   2024-01-22 15:37:00
大师
作者: ILoveErr (英梨梨我老婆)   2024-01-22 15:38:00
大师

Links booklink

Contact Us: admin [ a t ] ucptt.com