My first instinct was a nested loop and I almost went with it before catching myself.
Clarify the problem constraints (e.g., duplicates, order, output format) and then propose an efficient solution using a hash set to store pairs for O(1) lookups. Iterate through the array, and for each pair [a, b], check if the symmetric pair [b, a] exists in the set; if so, add both to the result (avoiding duplicates).
Pro tip: Mention that you can normalize pairs (e.g., sort each pair) to handle duplicates and avoid double-counting, and discuss trade-offs between time and space complexity. Also, consider edge cases like self-symmetric pairs (a == b) and whether they should be included.
Ask about input size, whether pairs can be duplicated, if the output should include each symmetric pair once or both, and if the order of pairs matters.
Use a hash set to store all pairs for O(1) lookups, or a hash map to count occurrences if duplicates need handling.
For each pair [a, b], check if [b, a] exists in the set. If it does and hasn't been added yet, include the pair in the result.
Use a visited set or normalize pairs to avoid adding the same symmetric pair twice. Consider self-symmetric pairs (a == b) and decide whether to include them.
State that the solution runs in O(n) time and O(n) space, where n is the number of pairs, and discuss possible optimizations if needed.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.