An auth server logs each session ID at login and again at logout. Two sessions never logged out, so their IDs appear once; every other ID appears exactly twice.
Write openSessions(ids) that returns the two unpaired IDs as [smaller, larger]. Use O(1) extra memory.
Input: ids = [1,2,1,3,2,5] Output: [3,5]
1 and 2 appear twice. 3 and 5 appear once.
Input: ids = [-1,0] Output: [-1,0]
Both IDs appear once.
2 <= ids.length <= 3 × 10^4-2^31 <= ids[i] <= 2^31 - 1Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #673 Two Unpaired Session IDs. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.