Skip to content
Programmingoneonone
Programmingoneonone
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone
Programmingoneonone

HackerRank CamelCase problem solution

YASH PAL, 31 July 202423 January 2026

HackerRank CamelCase problem solution – In this HackerRank CamelCase problem, 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.

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.

HackerRank CamelCase problem solution

HackerRank CamelCase problem solution in Python.

#!/bin/python3

import sys


s = input().strip()

count = 1
for letter in s:
    if ord(letter) <= ord('Z'):
        count += 1
print(count)

CamelCase problem 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();
        String p = s.toUpperCase();
        int l = s.length();
        int ans = 1;
        for (int i = 0; i < l; i++) {
            if (p.charAt(i) == s.charAt(i)) ans++;
        }
        
        System.out.println(ans);
    }
}

Problem solution in C++ programming.

#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 ans=1;
    for(int i=0; i<s.size(); i++) {
        if(s[i]>='A' && s[i]<='Z') ans++;
        
    }
    printf("%dn",ans);
    return 0;
}

Problem solution in C programming.

#include <stdio.h>
#include <string.h>

int main(void) {
	// your code goes here
	char inp[100005];
    int i,c=0,l;
	scanf("%s",inp);
	l=strlen(inp);
	for(i=0;i<l;i++)
	{
	    if(inp[i]>='A' && inp[i]<='Z')
	    c++;
	}
	printf("%dn",c+1);
	return 0;
}

Problem solution in JavaScript programming.

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();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

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

function main() {
    var s = readLine();
    var num = 0 ; 
    for(var i = 0; i< s.length ; i++){
        if(s.charCodeAt(i)>=65 && s.charCodeAt(i)<= 90)
            num++; 
    }
    num++; 
    console.log(num);
}

Algorithms coding problems solutions AlgorithmsHackerRank

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you a student and stuck with your career or worried about real-time things, and don't know how to manage your learning phase? Which profession to choose? and how to learn new things according to your goal, and land a dream job. Then this might help to you.

Hi My name is YASH PAL, founder of this Blog and a Senior Software engineer with 5+ years of Industry experience. I personally helped 40+ students to make a clear goal in their professional lives. Just book a one-on-one personal call with me for 30 minutes for 300 Rupees. Ask all your doubts and questions related to your career to set a clear roadmap for your professional life.

Book session - https://wa.me/qr/JQ2LAS7AASE2M1

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes