An Atlassian Confluence audit log is represented by a string s containing '0', '1', and '?'. Each '?' marks an unresolved event.
Determine whether every '?' can be replaced with '0' or '1' so that the resulting string contains no palindromic substring of length 5 or greater. Existing '0' and '1' characters must remain unchanged.
A substring is a contiguous segment. A palindrome reads the same forward and backward.
String checkPossibility(String s)
s: the audit log to validate."POSSIBLE" if at least one valid replacement exists; otherwise, return "IMPOSSIBLE".1 ≤ s.length() ≤ 50,000s contains only '0', '1', and '?'.s is never null.Input: checkPossibility(s = "01??10?1")
Output: "POSSIBLE"
Explanation: One valid replacement is "01011001", which contains no palindromic substring of length 5 or greater.
Input: checkPossibility(s = "10?01")
Output: "IMPOSSIBLE"
Explanation: The two replacements, "10001" and "10101", are both palindromes of length 5.
Input: checkPossibility(s = "011110")
Output: "IMPOSSIBLE"
Explanation: The entire string is a palindrome of length 6, and no character can be changed.
Input: checkPossibility(s = "?0?")
Output: "POSSIBLE"
Explanation: Replacing both unknown events with '0' gives "000". Its length is less than 5, so it is valid.