题目描述
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n
, find the one that is missing from the array.
Example 1:
1 |
Input: [3,0,1] |
Example 2:
1 |
Input: [9,6,4,2,3,5,7,0,1] |
通过数组的size可以求的如果没有少数字的时候的应有的数字和,然后用应有的减去实际的就可以得到缺少了点数字。
代码实现
1 |
class { |
近期评论