Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created July 25, 2016 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/75b984851f03cc369d1f59f41b6415f2 to your computer and use it in GitHub Desktop.
Save jianminchen/75b984851f03cc369d1f59f41b6415f2 to your computer and use it in GitHub Desktop.
Camel Case - HackerRank - world codesprint #5 - score 15/15
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