• + 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