Home | Projects | Notes > Problem Solving > LC - E - 268. Missing Number (bit manipulation)

LC - E - 268. Missing Number (bit manipulation)

 

Solutions in C++

Solution 1

This solution uses bit manipulation. XOR operations has the following properties:

Complexity Analysis:

Solution:

 

Solution 2

This solution uses the summation formula sumi=0n(n)=n(n+1)/2.

Complexity Analysis:

Solution:

 

Solution 3

This solution uses the std::sort algorithm.

Complexity Analysis:

Solution:

 

Solutions in C

Solution 1

This solution uses bit manipulation. XOR operations has the following properties:

Complexity Analysis:

Solution: