Re: [閒聊] 每日LeetCode

作者: JerryChungYC (JerryChung)   2024-01-22 13:22:12
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:
作者: JIWP (JIWP)   2024-01-22 13:50:00
大師前兩天是哪題阿
作者: sustainer123 (caster)   2024-01-22 13:55:00
動態規劃兩題ㄅ

Links booklink

Contact Us: admin [ a t ] ucptt.com