Web Crawler Multithreaded — LeetCode 1242 Python Solution
- Problem
- #1242
- Pattern
- Breadth-First Search
- Reading time
- 2 min
- Source
- leetcode.com
The problem
Given a URL startUrl and an interface HtmlParser, implement a Multi-threaded web crawler to crawl all links that are under the same hostname as startUrl. Return all URLs obtained by your web crawler in any order.
Example
interface HtmlParser {
// Return a list of all urls from a webpage of given url.
// This is a blocking call, that means it will do HTTP request and return when this request is finished.
public List<String> getUrls(String url);
}Complexity
| Measure | Complexity |
|---|---|
| Time | O(V+E) |
| Space | O(V) auxiliary |
Pattern: Breadth-First Search
Expand outward level by level, so the first time you arrive is the shortest way. LeetCode 1242. Web Crawler Multithreaded is filed here because LeetCode tags it Breadth-First Search, which is the vocabulary this hub collects.
The breadth-first search guide has the Python template for the pattern and the 233 LeetCode problems that use it.
Related problems
Frequently asked questions
- How hard is LeetCode 1242. Web Crawler Multithreaded?
- LeetCode 1242. Web Crawler Multithreaded is rated Medium on LeetCode.
- What is the time complexity of LeetCode 1242. Web Crawler Multithreaded?
- The Python solution on this page runs in O(V+E).
- What is the space complexity of LeetCode 1242. Web Crawler Multithreaded?
- The Python solution on this page uses O(V) auxiliary space.
- What topics does LeetCode 1242. Web Crawler Multithreaded cover?
- LeetCode 1242. Web Crawler Multithreaded is tagged Depth-First Search, Breadth-First Search and Concurrency on LeetCode.
- Is LeetCode 1242. Web Crawler Multithreaded a premium problem?
- Yes. LeetCode 1242. Web Crawler Multithreaded is a LeetCode Premium problem, so the full statement and test cases require a paid LeetCode subscription.