Mirror words

0

0 votes
String Algorithms, Easy-Medium
Problem

Identify words from the given sentence that are actually the reverse of each other. The words may be either consecutive or they could be separated with other words in the middle of them

For example in the sentence “He lived like a devil”, the words lived and devil are the reverse of each other.

Other examples “god made dog”, “each time it emit”, “raw war”

Input Format

Input contains a single line of all lower case string,

Str - Input String

Output Format

For each pair of mirror words in the Input String only once, print the the word and the mirror word separated by a space

Eg. For Input

he lived like a devil

the output should be

lived devil

and not

lived devil
devil lived

Note: Print the pair only once

Input Constraints

length of String is less than 200 characters(including spaces)

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?