Limited Time Offer:Up to 20% off Hello Interview Premium
Up to 20% off Hello Interview Premium 🎉
Hello Interview
Learn AI Coding
Introduction
Interview Formats
How to Prepare
Patterns
Codebase Orientation
Planning Your Approach
Driving the AI
Verification & Testing
Communication
Graph Search & Pathfinding
Topological Sort
Backtracking
Greedy & Bin Packing
Dynamic Programming
String Matching & Parsing
Data Structure Design
Battleship
Inventory Packer
Spell Checker
Card Game
Friend Recommender
Maze Solver
Route Planner
Task Scheduler
Word Container
Connect Four
Kitchen Orders
Maximize Unique Characters
Nonogram Solver
Pricing
Sign in / Sign up
Search
⌘K
Pricing

Tutor

Problem Breakdown

Word Container

String Matching & Parsing
Published ·
medium

Try This Problem Yourself

Practice in the AI-enabled editor with real-time feedback

You're given a list of words. Return every word that contains at least one other word from the list as a proper substring. "Proper" means strictly shorter, so "app" does not contain "app". The output preserves the order words appear in the input.
["apple", "app", "banana", "nana"]  →  ["apple", "banana"]
["work", "worker", "rework"]        →  ["worker", "rework"]
["cat", "dog", "bird"]              →  []
The surface area is tiny. The only knob is how you go about the substring check, and that's where the whole problem lives.
Pattern: String Matching & Parsing
The whole problem is deciding when one word sits inside another, which is substring matching. Picking the right structure to test containment quickly is what the string matching and parsing pattern is about.
Learn This Pattern

Solution 1, checking every pair

The most natural way to think about this is one word at a time. Take each word and ask whether any other word in the list fits inside it as a substring. If at least one does, then that word is a container and you can move on to the next candidate.

Complexity

Where it breaks

Solution 2, enumerating substrings instead of pairs

Complexity

Where it breaks

Solution 3, walking a structure instead of materializing substrings

Why the trie wins on long words

What about Aho-Corasick?

Benchmarks

Takeaways

Purchase Premium to Keep Reading

Unlock this article and so much more with Hello Interview Premium
Buy Premium

Guided Practice

Practice real problems with AI-powered feedback and hints.Start Guided Practice
Reading Progress

On This Page

Solution 1, checking every pair

Complexity

Where it breaks

Solution 2, enumerating substrings instead of pairs

Complexity

Where it breaks

Solution 3, walking a structure instead of materializing substrings

Why the trie wins on long words

What about Aho-Corasick?

Benchmarks

Takeaways

Questions
Meta SWE Interview QuestionsAmazon SWE Interview QuestionsGoogle SWE Interview QuestionsOpenAI SWE Interview QuestionsEngineering Manager (EM) Interview Questions
Learn
Learn System DesignLearn DSALearn BehavioralLearn ML System DesignLearn Low Level DesignGuided Practice
Links
FAQPricingGift PremiumHello Interview Premium
Legal
Terms and ConditionsPrivacy PolicySecurity
Contact
About UsProduct Support

7511 Greenwood Ave North Unit #4238 Seattle WA 98103


© 2026 Optick Labs Inc. All rights reserved.