I have an array of arrays that contains numbers in a specific order. I want to remove duplicates from nested arrays, but there is a hierarchy: if the number appears in the lower index of the array, delete all duplicates in the Array chain.
Example: nums = [[10, 6, 14], [6], [10, 6, 9], [10, 13, 6], [10, 13, 6, 9, 16], [10, 13] ]
nums [0] contains [10,6,14], so any subsequent mention of 10,6,14 should be removed from other arrays in the chain, that is, nums [2] should have 10,6 deleted and only 9 should remain.
I'm having problems with nested loops, can any Ruby wizards help?
source
share