CamelCase HackerRank Problem Solution in C++ | String - BeTech India!

Latest

BeTech India! - A place for all your Tech. needs | Solutions of Competitive Programming Problems | Code Explained | Indian Engineering System | Technology News | Current Updates | My Excerpts from Experiences | Coding Tips and much more...

Sunday, May 24, 2020

CamelCase HackerRank Problem Solution in C++ | String

#include <bits/stdc++.h>

using namespace std;
int main()
{
    string str;
    cin>>str;
    int len=str.length();
    
    int count=1;
    for(int i=0;i<len;)
    {
        if(isupper(str[i]) && i>-1)
            {
                count++;
                str.erase(i,1);
                i--;
            }
        else
            i++;
    }
    cout<<count<<endl;

    return 0;
}

No comments:

Post a Comment

Guys, if you have any doubts or suggestions please let us know.