A plagiarism checker for code submissions compares two files, each flattened into a string, and reports the length of the longest piece of text that appears in both.
Write longestShared(a, b) that returns the length of the longest string that is a substring of both a and b. Return 0 if they share no character.
Input: a = "xabcdy", b = "zzabcdq" Output: 4
abcd appears in both.
Input: a = "abc", b = "xyz" Output: 0
No character is shared.
0 <= a.length, b.length <= 10^4a and b contain lowercase letters.Run 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 #633 Longest Shared Fragment of Two Files. 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.