Your analytics tool records the user id of every page visit, in order, in visits. Marketing wants to know who came only once.
Write firstOneTimeVisitor(visits) that returns the first id (in visit order) that appears exactly once in visits. If every id appears more than once, or visits is empty, return null.
Input: visits = ["u1","u2","u1","u3","u2"] Output: "u3"
u1 and u2 came twice; u3 came once.
Input: visits = ["a","a"] Output: null
The only visitor came twice.
0 <= visits.length <= 10^5Run 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 #16 First One-Time Visitor. 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.