Sort by

recency

|

1908 Discussions

|

  • + 0 comments

    My Java 8 Solution

    public static int camelcase(String s) {
            int count = 1;
            
            for (char c : s.toCharArray()) {
                if (Character.isUpperCase(c)) {
                    count++;
                }
            }
            
            return count;
        }
    
  • + 0 comments

    my cpp solution for this programme

    int camelcase(string s) {

    int count=1;  //  count=1 for min 1 word
    for(int i = 0;i <s.size();i++){ // loop lessthan size
        if(s[i] < 'a')   //if less than lowescase than count++
        count++;
    }
    
    return count;
    

    }

  • + 0 comments

    def camelcase(s): # Write your code here wordCount = 1 for i in s: if "A" <= i <= "Z": wordCount += 1

    return wordCount
    
  • + 0 comments

    Here is a python O(n) time and O(1) space:

    def camelcase(s):
        if s == "":
            return 0
            
        w_count = 1;
        
        for ch in s:
            if ch.isupper():
                w_count += 1
                
        return w_count
    
  • + 0 comments

    Javascript

    function camelcase(s) {
        return [...s.matchAll(/[A-Z]/g)].length + 1
    }