Write a code to detect the first number having duplicate in below mentioned Array. Array = [4 1 2 5 8 1 3] Output would be 1. Note : You can use any coding or scripting language.
Utilisateur anonyme
RUBY: a = [4, 1, 2, 5, 8, 1, 3] b = a.detect do |e| a.count(e) > 1 end print b Output : 1