Recall & Review
beginner
What does the problem 'Count Words with Given Prefix' ask you to do?
It asks you to count how many words in a list start with a specific prefix string.
Click to reveal answer
beginner
Which JavaScript string method helps check if a word starts with a given prefix?
The
startsWith() method returns true if a string starts with the specified prefix.Click to reveal answer
beginner
How can you count words with a prefix using a simple loop in JavaScript?
Loop through each word, use
startsWith(prefix) to check, and increase a counter if true.Click to reveal answer
intermediate
What is a Trie and how can it help in counting words with a prefix?
A Trie is a tree-like data structure that stores words by their letters. It can quickly find how many words share a prefix by traversing the prefix path.
Click to reveal answer
intermediate
Why is using a Trie more efficient than checking each word individually for large datasets?
Because a Trie stores common prefixes once, it avoids repeated checks and can count prefix matches faster than scanning all words.
Click to reveal answer
Which JavaScript method checks if a string starts with a specific prefix?
✗ Incorrect
The
startsWith() method returns true if the string begins with the given prefix.What is the main task in 'Count Words with Given Prefix'?
✗ Incorrect
The problem requires counting words that start exactly with the given prefix.
Which data structure is best for efficient prefix searches?
✗ Incorrect
A Trie stores words by prefixes, making prefix searches very efficient.
If you have 1000 words and want to count prefix matches, what is a simple approach?
✗ Incorrect
Looping through each word and checking with
startsWith() is a straightforward method.What does the
startsWith() method return if the prefix is empty string?✗ Incorrect
An empty string is considered a prefix of any string, so
startsWith('') returns true.Explain how you would count words starting with a given prefix using JavaScript.
Think about checking each word one by one.
You got /3 concepts.
Describe what a Trie is and how it helps with prefix counting.
Imagine a tree where each branch is a letter.
You got /4 concepts.