You are given two arrays representing two sets of numbers.
The numbers are in any order, may have duplicates, and are
not necessarily consecutive.
The two arrays should have the same set of numbers but one
number is missing.
Write a C program to find the missing number.
Answer
The first approach is to sort the arrays and scan them for
the missing number.
Everyone I have discussed this problem with arrives at this solution.
The second solution is to take the sum of each array and subtract
the one with the extra element from the one with the missing
element. The difference is the missing number.
Background
This question was given during an in person interview on 1/17/2014 for
a firmware test engineer position.