268. Missing Number

Description:

https://leetcode.com/problems/missing-number/#/description

Algorithm:

  1. Use sum as shown in Code1.
  2. Use XOR

Code1:

Code2:

Time & Space:
O(n) & O(1)

Leave a Reply

Your email address will not be published. Required fields are marked *