Tap here to switch tabs
Problem
Submissions

Problem: Count the Number of Special Characters II

Count the Number of Special Characters II asks you to count letters in a string whose lowercase and uppercase forms both appear, with every lowercase occurrence before the first uppercase one.

Statement

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

Return the total number of special characters in word.

Constraints:

  • 1≤1 \leq word.length ≤2×105\leq 2 \times 10^5

  • word consists of only lowercase and uppercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count the Number of Special Characters II

Count the Number of Special Characters II asks you to count letters in a string whose lowercase and uppercase forms both appear, with every lowercase occurrence before the first uppercase one.

Statement

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

Return the total number of special characters in word.

Constraints:

  • 1≤1 \leq word.length ≤2×105\leq 2 \times 10^5

  • word consists of only lowercase and uppercase English letters.