0

Consider a length-\$n\$ array of positive integers.
The complement of the element with index \$i\$ is the element with index \$n - i\$.
The twin of an element \$a\$ is its complement after removing all elements not equal to \$a\$.
For example, in the array [1, 2, 3, 4, 2, 1, 3, 2], the compleme...