Pergunta de entrevista da empresa 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.

Respostas da entrevista

Sigiloso

16 de mai. de 2017

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

Sigiloso

7 de mai. de 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

Sigiloso

16 de nov. de 2016

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

2