How to find duplicates in an array and remove them
efficiently?
Answers were Sorted based on User's Feedback
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 |
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 |
What is the difference between QTP 8.2 and QTP 9.2
how we can do web browser using parametarisation in QTP ?
Tell me the QTP Advantages and Disadvatages ?
WHAT IS SMATR IDENTIFICATION? plz EXPLAIN BRIEFLY? IS IT POSSIBLE in QTP? HOW AND WHEn THE SITUATION U R USING EXPLAIN WITH EXAMPLE?
Which environments does qtp support?
what is Automation frame work and how do u used this for your project?
How to create an instance in QTP?
will QTP accepts javascript?
How to use the object spy in quicktest professional 8.0 version?
can anyone tell me how to search a word/line in a document and to paste it in another file? Thanks in advance.
What are the properties you would use for identifying a browser & page when using descriptive programming ?
i have data in excel sheet.i imported the data in data table.while doing parameterization,how the code knows it is a valid or invalid data?