#K79072. Categorize Strings as Polite or Rude
Categorize Strings as Polite or Rude
Categorize Strings as Polite or Rude
You are given a collection of strings, each representing a complaint or feedback message. A string is considered to be polite if no word occurs more than once, and rude if at least one word is repeated. Mathematically, a string is polite if and only if
$$\text{number of words} = \text{number of distinct words}, $$otherwise it is rude. Your task is to process each string and determine its category.
For example, the string "this is a good day" is polite because all words are unique, whereas "this is is rude" is rude because the word 'is' appears twice.
inputFormat
The first line of the input contains an integer (), representing the number of strings. This is followed by lines, each containing a string (which may include spaces) that represents a complaint or feedback.
outputFormat
For each test case, output a single line containing either "POLITE" if the string is polite or "RUDE" if the string is rude.## sample
4
this is a good day
be kind to others
this is is rude
politeness is important in service
POLITE
POLITE
RUDE
POLITE
</p>