Ctrl K

Same Text From Fragments

Easy
A long message arrived over two channels, and each time it was cut into pieces differently. You are given two lists of strings left and right; gluing a list's pieces together in order yields the text it carries. Return True if both lists carry exactly the same text, and False otherwise.
Example 1
left=["sun", "fl", "ower"], right=["sunflo", "wer"] → True

Both lists add up to "sunflower".

Example 2
left=["ab", "c"], right=["a", "cb"] → False

The left gives "abc", the right gives "acb".

Constraints
  • 1 ≤ len(left), len(right) ≤ 1000
  • 1 ≤ length of each piece ≤ 1000
  • The total length of pieces in each list is at most 1000
  • Pieces consist of lowercase Latin letters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsTwo Words, Closest Apart EasyOne-Row Typing EasyDinner for Two EasyPhrases with Synonyms EasyWord from a License Plate Easy
loading Python…
Input
left=["sun", "fl", "ower"], right=["sunflo", "wer"]
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 103 tests on the server, hidden ones included.