-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCamelCase.java
33 lines (28 loc) · 895 Bytes
/
CamelCase.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
Alice wrote 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, print the number of words in s on a new line.
Link: https://www.hackerrank.com/challenges/camelcase
*/
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 = 1; i < s.length(); i++) {
if (Character.isUpperCase(s.charAt(i)))
count++;
}
System.out.println(count);
}
}