Count the Number of Special Characters I

You are given a string `word`. A letter is called special if it appears both in lowercase and in uppercase somewhere in `word`. Return the number of special letters in `word`.

30:00

Count the Number of Special Characters I
easy
Free written solution
Topics
Companies

You are given a string word. A letter is called special if it appears both in lowercase and in uppercase somewhere in word. Return the number of special letters in word.

Example 1:
Input: {"word":"aaAbcBC"}
Output: 3
Constraints:
  • 1≤word.length≤501 \leq word.\text{length} \leq 50

  • word consists of only lowercase and uppercase English letters.

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"word":"aaAbcBC"}

word: lowercase · uppercase

a
a
A
b
c
B
C

each column: top = lowercase seen, bottom = uppercase seen · both on

a
A

b
B

c
C

d
D

e
E

f
F

g
G

h
H

i
I

j
J

k
K

l
L

m
M

n
N

o
O

p
P

q
Q

r
R

s
S

t
T

u
U

v
V

w
W

x
X

y
Y

z
Z

Two rows of 26 switches: the top row remembers lowercase letters, the bottom row uppercase ones.

count comes after the scan

Variables
VariableValue
count0
DepthFunction Call
Stack empty
0/12