आसान 0 हल किए गए 0% स्वीकृति

Count Uppercase Letters

Count the capital letters in a text.

आप क्या सीखेंगे

  • स्ट्रिंग के अक्षरों पर लूप चलाना
  • बड़े अक्षर पहचानना
  • मेल गिनना

समस्या

Count how many characters in text are uppercase English letters A–Z.

Implement count_uppercase(text).

Input

text: The text to inspect.

Output

Return the number of uppercase letters.

सीमाएँ

0 ≤ length of text ≤ 10,000 (ASCII characters)

उदाहरण

उदाहरण 1
इनपुट:
text = "Hello World"

अपेक्षित आउटपुट:
expected = 2
इनपुट:
std::string text = "Hello World";

अपेक्षित आउटपुट:
long long expected = 2;
इनपुट:
string text = "Hello World";

अपेक्षित आउटपुट:
long expected = 2;

व्याख्या

H and W are uppercase: 2.

उदाहरण 2
इनपुट:
text = "no caps here!"

अपेक्षित आउटपुट:
expected = 0
इनपुट:
std::string text = "no caps here!";

अपेक्षित आउटपुट:
long long expected = 0;
इनपुट:
string text = "no caps here!";

अपेक्षित आउटपुट:
long expected = 0;

व्याख्या

There are no uppercase letters: 0.

कैसे हल करें

पहले खुद कोशिश करें, फिर एक-एक करके संकेत खोलें।

संकेत 1

Text ko ek baar scan karo aur sirf A se Z tak ke letters count karo.

संकेत 2

Har character ka case directly check karo, words compare karne ya string split karne ki zarurat nahi.

संकेत 3

Yaad rahe, lowercase letters, digits, spaces, aur punctuation count mein nahi aate.

अपेक्षित जटिलता

समय O(n), अतिरिक्त स्थान O(1)

संदर्भ

यह चुनौती CodeUtility के लिए अनुकूलित की गई है। ऊपर दिए गए स्टेटमेंट और सीमाओं का पालन करें।

दूसरों से सीखें

समुदाय समाधान

अभी तक कोई प्रकाशित समाधान नहीं। पहला साझा करने के लिए इस चुनौती को हल करें।