CamelCase HackerRank Solution


CamelCase HackerRank Solution
Source : https://www.hackerrank.com/challenges/camelcase



Source : https://www.hackerrank.com/challenges/camelcase


Solution


// Karthikalapati.blogspot.com
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String str = scan.next();
scan.close();
System.out.println(numWords(str));
}
private static int numWords(String str) {
int count = 1;
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
if (ch >= 'A' && ch <= 'Z') {
count++;
}
}
return count;
}
}

No comments:

Post a Comment