#268.  Missing Number

Given an array containing n distinct numbers taken from `0, 1, 2, ..., n`, find the one that is missing from the array.

For example,
Given nums = `[0, 1, 3]` return `2`.

Note:
Your algorithm should run in linear runtime complexity. Could you implement it using only constant extra space complexity?

```class Solution {
public:
int missingNumber(vector<int>& nums) {
int len=nums.size();
int ret=;
for(int i=;i<len+;i++)
{
ret^=i;
}
for(int i=;i<len;i++)
{
ret^=nums[i];
}
return ret;
}
};```

## Leetcode-268 Missing Number More articles about

1. Java [Leetcode 268]Missing Number

Title Description : Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is ...

2. LeetCode 268. Missing Number （ Missing numbers ）

Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...

3. [LeetCode] 268. Missing Number *( Missing numbers )

Reprint :http://www.cnblogs.com/grandyang/p/4756677.html Given an array containing n distinct numbers take ...

4. [LeetCode] 268. Missing Number Missing numbers

Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...

5. 33. leetcode 268. Missing Number

Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...

6. LeetCode - 268. Missing Number - stable_sort Application example - ( C++ ) - Problem solving report

1. The main idea of the topic Given an array nums, write a function to move all 0's to the end of it while maintaining the ...

7. leetcode 268 Missing Number( The application of XOR operation )

Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...

8. Leetcode 268 Missing Number An operation

The question : First the 0, 1, 2, ..., n Put in an array , Then remove one of the values , Find that value . This question is related to singe number Is a type , The deformation is that the first thing you need to do is 0, 1, 2, ..., n Put it in this array again , ...

9. LeetCode 268. Missing Number Missing number (C++/Java)

subject : Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is mi ...

10. &amp;lt;LeetCode OJ&amp;gt; 268. Missing Number

268. Missing Number Total Accepted: 31740 Total Submissions: 83547 Difficulty: Medium Given an array ...

## Random recommendation

1. Atitit ACID Solution 2PC( Two-phase commit )&#160;&#160; Across multiple database instances ACID Guarantee

Atitit ACID Solution 2PC( Two-phase commit )   Across multiple database instances ACID Guarantee 1.1. ACID Solution 1 1.2. Database vendors have long recognized the need for database partitioning , And introduced a new method called 2PC( ...

2. 【 Baidu Maps API】 Establish a national bank location inquiry system （ Four ）—— How to use Baidu map data to generate their own annotations

original text :[ Baidu Maps API] Establish a national bank location inquiry system ( Four )-- How to use Baidu map data to generate their own annotations Abstract : Leave a suspense in the last chapter ," If you don't have a database of geographic coordinates , How to map the distribution of banks ?&quo ...

3. Oracle SQL Developer How to connect the database to the database configuration file

Oracle SQL Developer How to connect the database to the database configuration file 1. Database configuration file hibernate.connection.url jdbc:oracle:thin:@146.56.35 ...

4. obtain linux Help order

Classification of commands linux There are internal commands and external commands . Internal command means shell The program's own commands , yes shell Part of the program , These orders are made by shell The program identifies and is in shell The program runs internally , Usually in linux system ...

5. [Swift]LeetCode609. Find duplicate files in the system | Find Duplicate File in System

Given a list of directory info including directory path, and all the files with contents in this dir ...

6. H5 29-div and span label

29-div and span label --> Try so hard that nothing can be done , Struggle to move myself --> I am a div I am a div I am a span I am a span --> --> I'm a paragraph I'm the title --> ...

7. String There are several methods commonly used in this field

/* String(char[] value) Passing an array of characters Convert an array of characters to a string The character array does not query the encoding table */ public static void fun1(){ char[] ch = {'a', ...

8. Python Detect whether the host port is alive

#!/usr/bin/python3 import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) result = s ...

9. scriptcs brief introduction

One .scriptcs brief introduction scriptcs Easy to write and execute C # With a simple text editor . stay Visual Studio in , And other ideas , It's a powerful tool , They sometimes hinder productivity and promote it more than they do . You don't always ...

10. jsack

https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr016.html#BABGHEJB