Given a list of strings words and an integer n, return the words that are longer than n characters.
A word must be strictly longer than n: a word with exactly n characters is left out. Keep the words in the order they have in words. If no word is long enough, the result is empty.
Example 1:
Input: words = ["apple", "kiwi", "banana", "fig"], n = 4 Output: ["apple", "banana"] Explanation: apple has 5 characters and banana has 6. kiwi has exactly 4, so it is left out, and fig has only 3.
Example 2:
Input: words = ["hi", "to", "be"], n = 3 Output: [] Explanation: No word has more than 3 characters.
Example 3:
Input: words = ["go", "went", "gone", "went"], n = 3 Output: ["went", "gone", "went"] Explanation: Every word longer than 3 characters is kept, a repeated one too, in its original order.
Constraints:
wordshas at least one word, and every word is made of lowercase English letters.nis 0 or more.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
