Exercises/#110 Count Words in a String
#110

Count Words in a String

EasyπŸ”€ Strings
30 XP

Problem

Given a string, count the number of words (sequences of non-space characters). Handle multiple spaces.

Examples

Input: s = '  hello   world  '
Output: 2

Input: s = 'one two three'
Output: 3
string
AI Assistantβ€” powered by AI

Unlock hints progressively β€” start gentle, go deeper only if needed.

πŸ’‘

Level 1: Gentle Nudge

A subtle direction

πŸ—ΊοΈ

Level 2: Approach

The algorithm to use

πŸ”

Level 3: Detailed

Step-by-step guidance

110 / 150

Your Solution

⚑ JavaScript

to save progress and use AI features