Back to problems

Find All Distinct Pairs of Stocks

Algorithm · Amazon · Medium

Given a list stocks of non-negative stock price changes and an integer target_profit, return every unique unordered value pair (a, b) that can be formed from two different positions i and j in stocks such that stocks[i] + stocks[j] == target_profit and i != j. Pairs are unordered, so (a, b) and (b, a) are considered the same pair. If the same two values appear at multiple positions, include that value pair only once. A value may be paired with itself if it occurs at least…

Checking your access…