Words Compression
Bill has a sentence with n words and wants to compress it into a single word. To do this, he merges words from left to right. When merging two words, he removes the longest prefix of the second word that matches a suffix of the first word. For example, merging sample and please results in samplease
Given a sentence string. Each word consists of uppercase and lowercase English letters and digits. Return final compressed string.
Example 1
Input:
I want to order pizza
Output:
Iwantorderpizza
Example 2
Input:
sample please ease in out
Output:
sampleaseinout
main.cpp
C++
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla