Interview Question for Developer Program Engineers


Team: Dev
Country: India
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
0
of 0 vote

Keep storing in the HashMap..?

- naveenhooda2004 March 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

HashMap or helper hashset or othe (e.g tree) index on array,if data have to be strored in array for any reason

- tpcz March 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

Generally with some form of hash structure.

If you can't have another data structure, I guess it depends on the input data and the definition of 'scanned'. If faster than O(N) does not count as 'scanned' then you could insert the elements in sorted order and then discover whether an element is duplicate in O(log(N)).
If the input data is of a limited range (say integers from 0-100) then you could encode each value as a bit in a sequence of bytes and switch it to 1 when the element is entered, and then check if the bit is 1 whenever a new element is entered, rejecting the entry if the bit is already 1.

- Anonymous March 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What ever it may be Hash Map or Hash set, before inserting value it scans the complete array, So thts not the solution, May be we can use some trees, which was already sorted.

- Prashanth March 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

package com.kavitha.selfhelp;

import java.util.HashSet;
import java.util.Set;

public class StoreSet {

public static void main (String[] args){
Set <Integer> sampleset = new HashSet<Integer>();
System.out.println("No repetition see below: ");
for (String s : args){
Integer input = Integer.parseInt(s);
sampleset.add(input);
}

for(Integer setint : sampleset){
System.out.println( setint );
}
}
}

- Kavitha March 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what are the input values? is it just characters or can be anything?

- ajit March 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

integers

- premkumar1989.ss March 24, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int countingTable[128] = {0}; (Assuming ascii character set)
while (1) {
cin >> character;
if (countingTable[character] == 1) {
cout << "duplicate";
} else {
countingTable[character] = 1;
}
}

- Manish March 24, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More