← All problemsSign in

Last Words

Given a string $s$ consists of upper/lower-case alphabets and empty space characters ' ', print the length of last word (last word means the last appearing word if we loop from left to right) in the string. If the last word does not exist, print 0. Note: A word is defined as a maximal substring consisting of non-space characters only. ###Input: - First line will contain String $s$.

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start