← 返回 bloomberg 的题目列表Streaming Palindrome Checker with Sublinear Time Complexity
类型:online_judge
bloomberg
Design a class to determine if a stream of characters forms a palindrome. Implement two functions: track(char) to add a new character and isPalindrome() to check if the current character stream is a palindrome, returning True or False. The time complexity should be less than O(N). The input data stream could be in terabytes. For example, with the call sequence track('a'), track('b'), track('c'), track('b'), track('a'), calling isPalindrome() should return True.
Example
Input
abcba