Leetcode 268 - Missing Number

題目

Problem#

給你一個大小 $n$ 的不重覆整數陣列 nums,數字範圍 $[0, n]$,要你回傳唯一不在範圍內的數字。

測資限制#

  • $1 \le n \le 10^4$

想法#

用 hashmap 紀錄出現情況,接著去找不在的數字

AC Code#

  • 時間複雜度: $\mathcal{O}(n)$
  • 空間複雜度: $\mathcal{O}(n)$