Question d’entretien chez Amazon

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.

Réponses aux questions d'entretien

Utilisateur anonyme

16 mai 2017

RUBY: a = [4, 1, 2, 5, 8, 1, 3] b = a.detect do |e| a.count(e) > 1 end print b Output : 1

Utilisateur anonyme

7 mai 2021

public class Try { public static void main(String []args){ int[] a= {4,1,2,5,8,1,3,8}; int counter=1; for(int i=0;i

2

Utilisateur anonyme

16 nov. 2016

int a [] ={4,5,5,1,2,1,2}; loop:for(int i=0; i

2