This is a premium problem. We're working on making it available for free soon.
Use these hints if you're stuck. Try solving on your own first.
Use DFS/BFS to search start from the startURL. Remember to get rid of duplicate URLs.
Solutions for this premium problem will be available for free soon.
Browse Free ProblemsWatch expert explanations and walkthroughs
Practice problems asked by these companies to ace your technical interviews.
Explore More ProblemsJot down your thoughts, approach, and key learnings
Yes, variations of the Web Crawler problem are common in FAANG-style interviews. They test knowledge of graph traversal, string parsing, and handling visited states efficiently.
The optimal approach is to model the URLs as a graph and traverse it using either BFS or DFS. A visited set prevents revisiting the same page, while hostname filtering ensures only URLs from the same domain are crawled.
A hash set is essential to track visited URLs and avoid duplicates. For traversal, you can use a queue for BFS or a stack/recursion for DFS, depending on your preferred exploration order.
The problem restricts crawling to URLs belonging to the same hostname as the starting URL. This prevents the crawler from visiting unrelated domains and keeps the traversal limited to the intended website graph.