You are viewing a single comment's thread. Return to all comments →
An O(n) way that I used to get indices:
index1 = cost.index(number) + 1 index2 = cost.index(complement, 0 if number != complement else index1) + 1
If the number and compliment are the same, the second line starts searching for the index from where the first line found the index
Seems like cookies are disabled on this browser, please enable them to open this website
Hash Tables: Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
An O(n) way that I used to get indices:
If the number and compliment are the same, the second line starts searching for the index from where the first line found the index