P14391 [GeeksforGeeks] Check string1818
普及-
题目描述

Given a string, check if all its characters are the same or not.
Example 1:
Input:
s = "geeks"
Output: False
Explanation: The string contains different
character 'g', 'e', 'k' and 's'.
Example 2:
Input:
s = "gggg"
Output: True
Explanation: The string contains only one
character 'g'.
Your Task:
You don't need to read input or print anything. Your task is to complete the function check() which takes a string as input and returns True if all the characters in the string are the same. Else, it returns False.
Expected Time Complexity: O(|S|).
Expected Auxiliary Space: O(1).
Constraints:
1 <= |S| <= 10^{4}

输入格式

见题面

输出格式

见题面

样例输入
s = "geeks"
样例输出
False