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