Find duplicates in a file containing 6 digit number (like uid) in O (n) time.



Find duplicates in a file containing 6 digit number (like uid) in O (n) time...

Answer / Sharad Singh

Here is a solution using a hash table, which can find duplicates in O(n) time:n1. Read each line of the file and convert it to an integer.
2. If the integer is already in the hash table, it's a duplicate. Add it to the hash table otherwise.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()

1 Answers  


5. distance conversion: Convert a distance from miles to kilometers .there are 5280 feets per mile,12 inches per foot .2.54 centimeters per inch and 100000centimeters per kilometer

4 Answers  


what is ram?

3 Answers   TCS,


The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration

1 Answers  


How main function is called in c?

1 Answers  


Once I have used freopen, how can I get the original stdout (or stdin) back?

1 Answers  


What is the meaning of int *x[]();?

1 Answers  


How a string is stored in c?

1 Answers  


What is the benefit of using an enum rather than a #define constant?

1 Answers  


GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA

1 Answers  


What do you mean by a local block?

1 Answers   InterGraph,


What is structure padding in c?

1 Answers  


Categories