CamelCase

See the original problem on HackerRank.

Solutions

The problem is very simple: we just count how many capital letters the string has and we sum 1.

A C++ Solution:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <string>
#include <iostream>
#include <algorithm>
#include <iterator>

using namespace std;

int main()
{
    cout << (count_if(istream_iterator<char>(cin), istream_iterator<char>(), [](char c){
        return isupper(c);
    })+1);
}

Here is a Python solution by Yuri Valentini:

1
2
ss = raw_input().strip()
print map(operator.eq, ss, ss.lower()).count(False) +1
We've worked on this challenge in these gyms: modena 
comments powered by Disqus