A security scanner checks whether a leaked token token appears inside a log line line with its characters shuffled: some slice of line has exactly the same characters as token, each the same number of times.
Write containsShuffled(line, token) that returns true if such a slice exists, and false otherwise.
Input: line = "eidbaooo", token = "ab" Output: true
ba at index 3 uses the same letters as ab.
Input: line = "eidboaoo", token = "ab" Output: false
a and b are never next to each other.
1 <= line.length, token.length <= 100000Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #145 Hidden Shuffled Token. 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.