Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Coding puzzle (4)
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00665368
Message ID:
00665375
Views:
22
>For those who know about asymptotic behavior:
>
>Given an array of increasing numbers and a number X, create a linear algorithm that finds whether the array contains two numbers that sum to X (and those two numbers if they exist).
>
>Daniel

This should work (I think)

for i = 1 to alen(myarray)
for j = 1 to alen(myarray)
if myarray(i)+myarray(j) = X
return i,j
endi
next j
next i
Semper ubi sub ubi.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform