SelectSmart.comSelectSmart.com
Before you decide
Over 20,000 selectors
kspiller's flowchart create and edit page

▷ ▶ Three Sum SelectSmart.com free Computer flowcharts and decision trees.
ComputerThree Sum
By kspiller
Category: Computer. Viewed 383 times. Created December 2013.     Disclaimer.   
    Make your own flowchart
                
RATE THIS
FLOWCHART






Provided a 1D array of integers, find all combinations of 3 values from this set such that a+b+c=0

               
Does the combination i+j+k equal zero?
YES
Place vector i j k into s. Was that the last i j k combination?
YES
Is the front array element less than the back array element?
YES
Test the next array element
Put the rows in the ss vector

NO

NO



NO

NO



YES
Test a new combination for i+j+k
 
Swap the two elements. Was that the last element of the last row?
YES
Are the two columns of the same row the same?
NO
Then the rows are not equivalent! Is that the last row in the vector?







YES


NO
 
 
Test the next column
NO
Is it the last column of the row?
Test the next two rows







YES


 
 
 
The rows are equivalent! Do not print one of the rows in ss