![]() |
VOOZH | about |
Given a string, we have to find the longest word in the input string and then calculate the number of characters in this word.
Examples:
Input : A computer science portal for geeks
Output : Longest word's length = 8Input : I am an intern at geeksforgeeks
Output : Longest word's length = 13
The idea is simple, we traverse the given string. If we find end of word, we compare length of ended word with result. Else, we increment length of current word.
13
Another Approach:
13