Given an ArrayList of strings words, return an ArrayList of integers with the length of every word, in the same order as the words.
The length of a word is the number of letters it has.
Example 1:
Input: words = ["I", "love", "pancakes"] Output: [1, 4, 8] Explanation: "I" has 1 letter, "love" has 4 and "pancakes" has 8.
Example 2:
Input: words = ["banana", "kiwi", "fig"] Output: [6, 4, 3] Explanation: The lengths keep the order of the words: first "banana", then "kiwi", then "fig".
Example 3:
Input: words = ["code"] Output: [4] Explanation: One word gives one length.
Constraints:
wordshas at least one word.- Every word is made of English letters, lowercase or uppercase.
- The result has one length per word, in the same order as
words.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
