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++
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår