[leetcode] 268. Missing number

Given a sequence containing N numbers in 0, 1, 2,…, N, find the number in 0.. n that does not appear in the sequence.
Example 1:
Input: [3,0,1]
Output: 2
Example 2:
Input: [9,6,4,2,3,5,7,0,1]
Output: 8

Your algorithm should have linear time complexity. Can you just use the extra constant space?

Solution code:

[leetcode] 268. Missing number

Recommended Today

Implementation example of go operation etcd

etcdIt is an open-source, distributed key value pair data storage system, which provides shared configuration, service registration and discovery. This paper mainly introduces the installation and use of etcd. Etcdetcd introduction etcdIt is an open source and highly available distributed key value storage system developed with go language, which can be used to configure sharing […]