Skip to content

Instantly share code, notes, and snippets.

@jackson-rz
jackson-rz / Solution.java
Created November 22, 2019 14:38
Multithreaded web Crawler
class Solution {
public List<String> crawl(String startUrl, HtmlParser htmlParser) {
// find hostname
int index = startUrl.indexOf('/', 7);
String hostname = (index != -1) ? startUrl.substring(0, index) : startUrl;
// multi-thread
Crawler crawler = new Crawler(startUrl, hostname, htmlParser);
crawler.result = new HashSet<>(); // reset result as static property belongs to class, it will go through all of the test cases
class Solution(object):
def uniquechar(self, string):
if string == '':
return True
string = sorted(string)
prev = string[0]
for char in string[1:]:
if char == prev: