Computer Science, asked by danieljoshua509, 9 months ago

Given a string S with spaces, the program must print only the words having it's first letter same as the last letter of the previous word. If no such word matches the specified condition print -1. Boundary conditions: 1<=length of s1<=1000 Input format: The first line contains S. Output format: The first line contains the specified output. Example 1: Input: word dove think yellow wood Output: dove wood Example 2: Input: mint hen bob jack Output: -1 Please solve this program in C language or python3 (3.x)

Answers

Answered by Anonymous
0

Answer:

Hello,

Could someone explain the concept of word

A word boundary \b says "in this place, a word character is expected." In your second example, this means a word character is expected before the "@" and the last matching character must proceed a word character.

Since some of the matches in the first group end in a newline character "\n", they will be rejected by the second pattern.

The boundary character is an anchor that says a word character must be hear but it doesn't "consume" the character into the results. You may think of it like a word match character "\w" that doesn't hold on to the match results.

Similar questions