An analytics tool recorded the event names of three user sessions, first, second, and third, in time order. A product manager wants the longest list of events that happens in all three sessions in the same order, with other events allowed in between.
Write commonSteps(first, second, third) that returns the length of the longest common subsequence of the three arrays.
Input: first = ["view","cart","pay"], second = ["view","pay"], third = ["view","search","pay"] Output: 2
view then pay happens in all three sessions.
Input: first = ["open"], second = ["close"], third = ["open"] Output: 0
No event appears in all three.
0 <= first.length, second.length, third.length <= 100Run 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 #535 Common Steps Across Three Funnels. 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.