Created
July 25, 2016 05:49
-
-
Save jianminchen/75b984851f03cc369d1f59f41b6415f2 to your computer and use it in GitHub Desktop.
Camel Case - HackerRank - world codesprint #5 - score 15/15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace CamelCase | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string s = Console.ReadLine(); | |
//string s1 = "saveChangesInTheEditor"; | |
Console.WriteLine(getNumberWords(s)); | |
} | |
public static int getNumberWords(string s) | |
{ | |
if (s == null || s.Length == 0) | |
return 0; | |
string alphabetic = "ABCDEDFGHIJKLMNOPQRSTUVWXYZ"; | |
int count = 1; | |
for(int i=0; i < s.Length; i++) | |
{ | |
char c = s[i]; | |
char[] arr = alphabetic.ToArray(); | |
if (Array.IndexOf(arr, c) != -1) | |
count++; | |
} | |
return count; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment