Find the missing number in a consecutive array.
Given an array containing n distinct integers from 0 through n, return the one missing integer. The array is not necessarily sorted, and the solution should run in O(n) time with O(1) extra space.
def missing_number(nums):