I am quite new to ruby so bear with me, I have two arrays and we are meant to find the number which is missing.
The starting array sequence is [1,2,3,4,5,6,7,8,9] The mi
Use Array Difference
[1,2,3,4,5,6,7,8,9] - [3,2,4,6,7,8,1,9]
#=> [5]
From the docs:
ary - other_ary → new_ary
Returns a new array that is a copy of the original array, removing any items that also appear in other_ary. The order is preserved from the original array.
It compares elements using their
hash
andeql?
methods for efficiency