Some error occured while loading page for you. Please try again.
Sunny and Johnny like to pool their money and go to the ice cream parlor. Johnny never buys the same flavor that Sunny does. The only other rule they have is that they spend all of their money.
Given a list of prices for the flavors of ice cream, select the two that will cost all of the money they have.
For example, they have to spend and there are flavors costing . The two flavors costing and meet the criteria. Using -based indexing, they are at indices and .
Complete the icecreamParlor function in the editor below. It should return an array containing the indices of the prices of the two flavors they buy, sorted ascending.
icecreamParlor has the following parameter(s):
The first line contains an integer, , denoting the number of trips to the ice cream parlor. The next sets of lines each describe a visit. Each trip is described as follows:
Note: The index within the cost array represents the flavor of the ice cream purchased.
For each test case, print two space-separated integers denoting the indices of the two flavors purchased, in ascending order.
1 4 5 3 2
2 2 4 3
Sunny and Johnny make the following two trips to the parlor: