I have an array which can have N nested array where N can contain M arrays where both N and M are >= 1. Some examples include the following:
[[[1,2,3],[3,4,5]],[[2,1,1]]]
or
[[[1,2,3]],[]]]
and finally
[[[1,2,3],[3,4,5]],[[2,1,1]], [[1,1,1],[2,2,2]]]
I need something that returns a boolean true or false if there is a duplicate value for the 0th element in a nested array, the issue is the composite array is not the unique identifier. Only the 0th element in each value array such as [1,2,3] or [3,4,5], in this case the integers 1 and 3, are what I need a unique against. so in the case of the last array, [1,1,1] and [1,2,3] would clash as the 1 is repeated.
What’s the best way to iterate through this type of nesting and signal true or false on whether there are duplicates?
1 Answer