Easy
Check whether the given string is a subsequence of the plaintext alphabet.
Example
- For s = "effg", the output should be
alphabetSubsequence(s) = false; - For s = "cdce", the output should be
alphabetSubsequence(s) = false; - For s = "ace", the output should be
alphabetSubsequence(s) = true; - For s = "bxz", the output should be
alphabetSubsequence(s) = true.
Input/Output
-
[execution time limit] 0.5 seconds (c)
-
[input] string s
Guaranteed constraints:
2 ≤ s.length ≤ 15. -
[output] boolean
- true if the given string is a subsequence of the alphabet, false otherwise.
[C] Syntax Tips
// Prints help message to the console
// Returns a string
char * helloWorld(char * name) {
char * answer = malloc(strlen(name) + 8);
printf("This prints to the console when you Run Tests");
strcpy(answer, "Hello, ");
strcat(answer, name);
return answer;
}
더보기
Solution
bool alphabetSubsequence(char *s)
{
for(int i=1;i<strlen(s);i++)
if(s[i]<=s[i-1])
return false;
return true;
}
728x90
'Codesignal' 카테고리의 다른 글
<Codesignal> Switch Lights (0) | 2020.05.04 |
---|---|
<Codesignal> Minimal Number of Coins (0) | 2020.05.04 |
<Codesignal> House of Cats (0) | 2020.05.04 |
<Codesignal> House Numbers Sum (0) | 2020.05.03 |
<Codesignal> Numbers of Clans (0) | 2020.05.03 |