Skip to main content

TCS

TCS OA-5 2024

Problem Description

Remove all the duplicate words from the string. 
Duplicate words are the ones which occurs more than ones in a string.

Input Format

  • The first line contains a string S.

Output Format

Print the modified string S after removing all the duplicate words.

Constraints

  • 1 ≤ S.length ≤ 10³

Example

Sample Input:

hello people hello world 

Sample Output:

hello people world

Explanation:

"hello" is eliminated as it's duplicate.