Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.

book
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

main.cpp

C++

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt