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

Hi Frriends... I have one Query please give the apropriate ans. when we r working with web based application , the user loggedin page name is changed respect to the username ( Take a exp. Yahoomail.com) .When we use Datadriven test to this scenario ,each time the loggedin page name is changed ...then the script is fail.. at that time wat can do... please give the apropriate ans. Thanx in advance..

3 Answers  


Hello friends can anybody tell me about the architecture of QTP with diagram of it.this architecture is same for any domain like ERP/Banking/CRM/Healthcare or it's different then please tell me.thanks

4 Answers   Fidelity,


How can I use the value retrieved by OUTPUT VALUE check point as Input for other Actions?

1 Answers   Motorola,


How can i Save the snapshots in a specified folders using Scripting in QTP?

1 Answers  


4. what is the use of Text output value in Qtp?

1 Answers   Wipro,






What is difference between WR and QTP?

2 Answers  


Hi Friends,I hav Just finished QTP course.Can any body suggest me which is the best place to go and post resume(Ban,Chennai,Pune,Mumbai,NCR,Kolkata).I mean how r calls in these cities,the best one?

3 Answers  


How did you achieve reusability via QTP?

1 Answers  


What is quick test pro?

0 Answers  


how to run the script If QTP tool not identify object in web page

2 Answers  


How to covert a String to an integer?

5 Answers  


What is an object repository?

0 Answers  


Categories