FastPrepFastPrep
Problem Brief

Compute Difference Between Uppercase and Lowercase Letters

INTERNOA

Note ->> See the Image Source section at the very bottom of the page for the original problem statement and etc.. 🐰🐰

100 years agoo0, a typing practice app wanted to test how well users balanced uppercase and lowercase letters in their entries. For every string a user typed, the app needed to count the number of uppercase and lowercase letters and calculate the difference between them—positive if uppercase dominated, negative if lowercase took the lead. It didn’t mind if the solution wasn’t the most efficient, as long as it could handle the text without breaking a sweat, even if it meant checking some letters more than once. With your help, the app could ensure everything stayed consistent and fun!

𓍢ִ໋🌷͙֒ ᩚMany thanks to Charlotte babyᰔ

1Example 1

Input
text = "CodeSignal"
Output
-6
Explanation
In the given text, there are 2 uppercase letters ('C' and 'S') and 8 lowercase letters ('o', 'd', 'e', 'S', 'i', 'g', 'n', 'a', 'l'). This results in a difference of 2 - 8 = -6.

2Example 2

Input
text = "a"
Output
-1
Explanation
The text contains just 1 lowercase letter ('a') and no uppercase letters. So, the difference is 0 - 1 = -1.

Constraints

Limits and guarantees your solution can rely on.

  • 0 ≤ typedText.length ≤ 100.
public int computeDiff(String text) {
  // write your code here
}
Input

text

"CodeSignal"

Output

-6

Sign in to submit your solution.