Ctrl K

Letters in Both Cases

Easy
You get a string text made of English letters. Call a letter two-faced if it appears in text both in lowercase and in uppercase (for example, both q and Q). Return the number of distinct two-faced letters.
Example 1
text="BoatbOAt" → 3

b, o and a appear both in lowercase and in uppercase, while t is only lowercase. The answer is 3.

Example 2
text="HELLO" → 0

There are no lowercase letters at all, so the answer is 0.

Example 3
text="xYyX" → 2
Constraints
  • 1 ≤ len(text) ≤ 50
  • text consists only of lowercase and uppercase English letters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasySame Letter Cipher EasySame Letters, Reshuffled EasySame When Flipped EasyShuffle Into a Palindrome Easy
loading Python…
Input
text="BoatbOAt"
Expected
3

Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.