filmov
tv
268 Missing Number Leetcode Python Solution

Показать описание
268,Missing,Number,Leetcode,Python,Solution
268 Missing Number Leetcode Python Solution
268 Missing Number Leetcode Python Solution
Solution:
"""
The xor solution uses the concept of "pair of same number, when xored among themselves yields a missing pair number" as seen thin the "Contains Duplicate" question.
4^4=0
4^0=4
4^7^6^6^4^7=0 contains all the pairs
4^7^6^4^7=6 missing pair of 6
Therefore if we do xor with array number with index of array we will end up with the missing pair i.e. the missing number
"""
268 Missing Number Leetcode Python Solution
268 Missing Number Leetcode Python Solution
Solution:
"""
The xor solution uses the concept of "pair of same number, when xored among themselves yields a missing pair number" as seen thin the "Contains Duplicate" question.
4^4=0
4^0=4
4^7^6^6^4^7=0 contains all the pairs
4^7^6^4^7=6 missing pair of 6
Therefore if we do xor with array number with index of array we will end up with the missing pair i.e. the missing number
"""