Intuition:

To find the power of the string, we need to determine the maximum length of a non-empty substring that contains only one unique character. We can achieve this by iterating through the string and keeping track of the current character and its consecutive count. Whenever we encounter a different character, we update the maximum consecutive count encountered so far. By doing this, we can find the power of the string efficiently.

Solution:

def string_power(s: str) -> int:
    # Initialize variables to store the maximum power and consecutive count
    max_power = 0
    consecutive_count = 1
    
    # Iterate through the string starting from the second character
    for i in range(1, len(s)):
        # If the current character is the same as the previous one, increment the consecutive count
        if s[i] == s[i - 1]:
            consecutive_count += 1
        else:
            # If the current character is different, update the maximum power and reset the consecutive count
            max_power = max(max_power, consecutive_count)
            consecutive_count = 1
    
    # Update the maximum power after processing the last character
    max_power = max(max_power, consecutive_count)
    
    return max_power

# Test cases
s = "abbcccddddeeeeedcba"
result = string_power(s)
print(result)  # Output should be 5

s = "triplepillooooow"
result = string_power(s)
print(result)  # Output should be 5

s = "hooraaaaaaaaaaay"
result = string_power(s)
print(result)  # Output should be 11

s = "tourist"
result = string_power(s)
print(result)  # Output should be 1

Time Complexity:

We iterate through the string once to determine the maximum consecutive count. The time complexity of this approach is O(n), where n is the length of the input string s.

Space Complexity:

The space complexity is O(1) as we use only a constant amount of additional space for variables.