Intuit Interview Question: Given an array of 1000 elemen... | Glassdoor

Interview Question

Software Engineer Intern Interview(Student Candidate) Boston, MA

Given an array of 1000 element, how will you find the

  element repeated twice in O(n) complexity

Interview Answer

2 Answers


Put the numbers in a hash table

MacManiac on Feb 26, 2013

Assuming you print out the twice-repeated element:

void findDuplicate(char arr[1000]){
     unordered_map charCount;

     for(int i = 0; i second == 2) cout second << endl;

Anonymous on Jan 22, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.