Write a program to find duplicate number from array in minimum time complexity.



Write a program to find duplicate number from array in minimum time complexity...

Answer / Shivanshu

In many programming languages, the built-in data structures like sets or hash maps can be used to efficiently find duplicates in an array. Here is an example using Python:
```
numbers = [1, 2, 3, 4, 4, 5, 6]
duplicates = set()
for num in numbers:
if num in duplicates:
print(num)
else:
duplicates.add(num)
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Programming Languages AllOther Interview Questions

explain how to make a control visible and invisible during runtime

3 Answers  


To sorting array of 10 elements which sorting is best a)selection b)bubble c)tree sort

2 Answers   HP, Hughes,


What is diffrent between Method and and function in c#

1 Answers  


3. . Explain the Cache memory? What is the advantage of a processor having more cache memory?

1 Answers  


Explain with examples any 2 features of OOPS.

1 Answers   Tavant Technologies, Verifone,


Write a program to show polymorphism.

1 Answers   Genpact,


Wrtite a JCL for sorting a file with start from 36 postion lenth 9 excluding a num eq to 98768. for 3 marks mainframe

1 Answers  


what is the difference between an OS(operating system) and Framework?

1 Answers  


can we extend a class having only one parameterised constructor.Suggest the process to do it.

0 Answers   Zensar,


why we use abstract word in abstract window toolkit in java language.

1 Answers   Infosys,


I've an application where i need to give access to all the features only to admin and only few features to normal users. Say Menu...i dont want all my menu items to be accessible to all the users only the admin people can see few all the features where as normal users can have access to limited menu items...how can i achieve this. Please note that my menu is not a database driven menu.

1 Answers   Tesco,


Given a Binary Search Tree, write a program to print the kth smallest element without using any static/global variable. You can?t pass the value k to any function also.

1 Answers   Amazon,


Categories