Created With

linkFind The Missing Number

You are given an array A of n-1 integers which are in the range between 1 and n. All numbers appear exactly once, except one number, which is missing. Find this missing number.

missing.py
1linkn = 5

2linka = [3, 5, 1, 4]

3link

4linkoriginal = list(range(1, n+1) # [1, 2, 3, 4, 5]

5linkmissing = 0

6linkfor v in a+orig: # [3, 5, 1, 4, 1, 2, 3, 4, 5]

7link missing ^= v

8link

9linkprint(missing)

description

15-Feb-2021

Find The Missing Number

Home

Awesome Stuff

Project Eulerchevron_right
Essayschevron_right
Blogschevron_right