is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
couldn't we just do this by iterating through the cells in the matrix once, with a runtime linear to the amount of cells, by keeping track of the visited land? O(n*m)
- samantha November 21, 2016algorithm:
initialize an island counter.
for each cell in the matrix,
if cell is unvisited land, then mark land as visited. (this can be done destructively, or if the backing data are booleans, then with a mirrored data structure.)
if cell is not adjacent to visited land, then increment the island counter (note: we may decrement the island counter later on if multiple islands end up joining together.)
if cell is adjacent to 2-4 visited lands, then decrement the island counter by the number of adjacent visited land(s) - 1.
after visiting each cell in the matrix, return the island counter