Perfect Password

Medium
string substring hash-set validation
Problem Description

A password is "perfect" if it contains no repeating substring of length 3 or more. Given a password string, determine if it qualifies as a perfect password. Substrings of length 1 and 2 can repeat.

Input Format
A single string representing the password.
Output Format
Return "PERFECT" if the password is perfect, "NOT PERFECT" otherwise.
Constraints
• 1 ≤ password length ≤ 1000
• Password contains only lowercase letters and digits
• Check for repeating substrings of length ≥ 3
• Substrings of length 1 and 2 can repeat
• Case-sensitive comparison
Sample Input/Output
Input:
abcabc
Output:
NOT PERFECT
Explanation

The password "abcabc" contains the repeating substring "abc" which appears twice. Since this substring has length 3 (≥ 3), the password is not perfect.

Solution Hints
95
Points
2000ms
Time Limit
128MB
Memory Limit
Code Editor
Register to Submit
Register to Access Code Editor

Create a free account to solve coding problems and track your progress.

Register Now
Feedback