# HackerRank CamelCase Solution

Hello Programmers, In this post, you will learn how to solve HackerRank CamelCase Solution. This problem is a part of the HackerRank Algorithms Series.

One more thing to add, don’t straight away look for the solutions, first try to solve the problems by yourself. If you find any difficulty after trying several times, then look for the solutions. We are going to solve the HackerRank Algorithms problems using C, CPP, JAVA, PYTHON, JavaScript & SCALA Programming Languages.

## HackerRank CamelCase Solution

There is a sequence of words in CamelCase as a string of letters, s, having the following properties:

• It is a concatenation of one or more words consisting of English letters.
• All letters in the first word are lowercase.
• For each of the subsequent words, the first letter is uppercase and rest of the letters are lowercase.

Given s, determine the number of words in s.

Example

s = oneTwoThree

There are 3 words in the string: ‘one’, ‘Two’, ‘Three’.

Function Description

Complete the camelcase function in the editor below.

camelcase has the following parameter(s):

• string s: the string to analyze

Returns

• int: the number of words in s

Input Format

A single line containing string s.

Constraints

• 1 <= length of s <= 105

Sample Input

saveChangesInTheEditor

Sample Output

5

Explanation

String  contains five words:

1. save
2. Changes
3. In
4. The
5. Editor

## HackerRank CamelCase Solution

### HackerRank CamelCase Solution

```#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
char* s = (char *)malloc(10240 * sizeof(char));
scanf("%s",s);
int coun=0,i;
for(i=0;i<strlen(s);i++)
{
if(s[i]>=65 && s[i]<=90){coun++;}
}
printf("%d\n",coun+1);
return 0;
}```

### HackerRank CamelCase Solution in Cpp

```#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main(){
string s;
cin >> s;
int t=1;
for (int i=0;i<s.length();i++)
if (isupper(s[i]))
t++;
cout<<t<<endl;
return 0;
}```

### HackerRank CamelCase Solution in Java

```import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.next();
int count = 1;
for(int i = 0; i<s.length(); i++){
char c = s.charAt(i);
if(c>='A' && c<='Z') count++;
}
System.out.println(count);
}
}```

### HackerRank CamelCase Solution in Python

```#!/bin/python

import sys

s = raw_input().strip()
count=0
for i in s:
if i.upper()==i:
count+=1
print count+1```

### HackerRank CamelCase Solution using JavaScript

```process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
input_stdin += data;
});

process.stdin.on('end', function () {
input_stdin_array = input_stdin.split("\n");
main();
});

return input_stdin_array[input_currentline++];
}

/////////////// ignore above this line ////////////////////

function main() {
let array = s.split(/(?=[A-Z])/);
console.log(array.length);
}```

### HackerRank CamelCase Solution in Scala

```import scala.io.StdIn._

object Solution extends App {
val counter = str.count(c => Character.isUpperCase(c))
println(counter + 1)
}```

### HackerRank CamelCase Solution in Pascal

```var n,d,i:longint;
s:ansistring;
begin