How to find duplicates in an array and remove them
efficiently?

Answers were Sorted based on User's Feedback



How to find duplicates in an array and remove them efficiently?..

Answer / vishnu


Dim a(4)

a(0) = 1
a(1) = 4
a(2) = 5
a(3) = 4
a(4) = 5

For i = ubound(a)-1 to 0 step - 1
For j=0 to i
If a(j) = a(j+1) Then
a(j) = empty
ElseIf a(j)>a(j+1) Then
temp = a(j+1)
a(j+1) = a(j)
a(j) = temp
End If
Next
Next

For i=0 to ubound(a)
print a(i)
Next

Is This Answer Correct ?    1 Yes 0 No

How to find duplicates in an array and remove them efficiently?..

Answer / crazy boy

**How to find duplicates in an array and remove them efficiently?
=================================================
dim a(4)
a(0)=10
a(1)=20
a(2)=10
a(3)=20
a(4)=50

for i=0 to ubound(a)
for j=i+1 to ubound(a)
if a(i)=a(j) then
a(i) =empty
end if
next
next

for i=0 to ubound(a)
if a(i)<>"" then
msgbox a(i)
end if
next

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More QTP Interview Questions

how qtp identifies objects of application.

5 Answers   Intel,


Explain types of descriptive programming?

0 Answers  


How can we export test results to an excel sheet in QTP??? Can any one provide sample coding for this?????

6 Answers   TCS,


What is method name to compare two XML files.

0 Answers  


how can you describe the basic flow of automation with conditional and programmatic logic?

1 Answers   Ordain Solutions,






why require regression testing?

2 Answers   TCS,


Explain the concept of object repository and how qtp recognises objects?

0 Answers  


how can we know the program is testing by multiple test data in data driven frame work?

1 Answers   CTS,


what is batch run ?

4 Answers   HCL,


Why is action split used by qtp?

0 Answers  


How to explain a banking project in interview as a test engineer???

0 Answers   Accenture,


Hi All, I need code for how to execute qtp scripts from excell sheet

0 Answers  


Categories