Link

Complexity:

time complexity is O(N)

space complexity is O(1)

Execution:

Since the input always has at least 1 character, we can assume that there will always be at least one word. Each upper case later identifies the next word. So the result is number of capital letters + 1.