java.lang.Object
g3101_3200.s3121_count_the_number_of_special_characters_ii.Solution

public class Solution extends java.lang.Object
3121 - Count the Number of Special Characters II.

Medium

You are given a string word. A letter c is called special if it appears both in lowercase and uppercase in word, and every lowercase occurrence of c appears before the first uppercase occurrence of c.

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:

  • 1 <= word.length <= 2 * 105
  • word consists of only lowercase and uppercase English letters.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    numberOfSpecialChars(java.lang.String word)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • numberOfSpecialChars

      public int numberOfSpecialChars(java.lang.String word)