I had a front end phone interview with Amazon today. Just basic questions on how to come up with front end system design, and best practices. Like how to design a newspaper site. How to find errors. How to improve performance.
Coding question was:
/* Imagine we have a page that displays logs from our website in a table. Given these logs, write a function that tests whether a one URL
is linked to another URL, even if it take more than one link to get there. For example:
areURLsLinked("/", "/search") => true
areURLsLinked("/", "/reviews") => true
areURLsLinked("/", "/robots.txt") => false
URL Session ID Timestamp Referrer
/ C4CA4238A0B923820DCC509A6F75849B 1625153267 NULL
/ C4CA4238A0B923820DCC509A6F75849B 1625153254 /
/search C4CA4238A0B923820DCC509A6F75849B 1625153298 /
/detail C4CA4238A0B923820DCC509A6F75849B 1625153298 /search
/reviews C4CA4238A0B923820DCC509A6F75849B 1625153298 /detail
/help ECCBC87E4B5CE2FE28308FD9F2A7BAF3 1625153314 /
/ ECCBC87E4B5CE2FE28308FD9F2A7BAF3 1625153320 /search
/cart C4CA4238A0B923820DCC509A6F75849B 1625153325 /detail
/cart ECCBC87E4B5CE2FE28308FD9F2A7BAF3 1625153332 /search
/robots.txt C81E728D9D4C2F636F067F89CC14862C 1625153340 NULL
*/
Whats the best way to get this? I used recursion and hash to keep track of previously accessed URL's so endless loops are avoided.
Thanks
Comments (2)


