Class Solution
-
- All Implemented Interfaces:
public final class Solution3121 - Count the Number of Special Characters II.
Medium
You are given a string
word. A lettercis called special if it appears both in lowercase and uppercase inword, and every lowercase occurrence ofcappears before the first uppercase occurrence ofc.Return the number of special letters in
word.Example 1:
Input: word = "aaAbcBC"
Output: 3
Explanation:
The special characters are
'a','b', and'c'.Example 2:
Input: word = "abc"
Output: 0
Explanation:
There are no special characters in
word.Example 3:
Input: word = "AbBCab"
Output: 0
Explanation:
There are no special characters in
word.Constraints:
<code>1 <= word.length <= 2 * 10<sup>5</sup></code>
wordconsists of only lowercase and uppercase English letters.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegernumberOfSpecialChars(String word)-
-
Method Detail
-
numberOfSpecialChars
final Integer numberOfSpecialChars(String word)
-
-
-
-