Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank, Algorithm Solutions of Problem Solving Section in Java. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.
In this post, you will find the solution for CamelCase in Java-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.
Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.
Introduction To Algorithm
The word Algorithm means “a process or set of rules to be followed in calculations or other problem-solving operations”. Therefore Algorithm refers to a set of rules/instructions that step-by-step define how a work is to be executed upon in order to get the expected results.
Advantages of Algorithms:
- It is easy to understand.
- Algorithm is a step-wise representation of a solution to a given problem.
- In Algorithm the problem is broken down into smaller pieces or steps hence, it is easier for the programmer to convert it into an actual program.
Link for the Problem – CamelCase – Hacker Rank Solution
CamelCase – Hacker Rank Solution
Problem:
There is a sequence of words in CamelCase as a string of letters, , 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 , determine the number of words in .
Example
There are 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
Input Format
A single line containing string .
Constraints
![CamelCase in Algorithm | HackerRank Programming Solutions | HackerRank Problem Solving Solutions in Java [💯Correct] 2 image 85](https://technorj.com/wp-content/uploads/2021/12/image-85.png)
Sample Input
saveChangesInTheEditor
Sample Output
5
Explanation
String contains five words:
- save
- Changes
- In
- The
- Editor
CamelCase – Hacker Rank Solution
import java.util.Scanner; /** * @author Techno-RJ * */ public class CamelCase { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); int count = 1; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) >= 65 && s.charAt(i) <= 90) { count++; } } System.out.println(count); sc.close(); } }