Google L4
Anonymous User
542

Company: Google
Stage: Onsite

Problem :Given a tree having nodes with value 0 and 1. write a function to return the number of islands ?

My solution:
I Solved this problem with recurssive approach with help of a Global variable. But then interviewer asked me to do it without global varaible . I did that with refernce value (in cpp) . then Interviewer asked me to remove that ref. variable as well. then I solved it without it.
In the end he was satisfied by my solution.

Follow up
I've to return all distinct size of island. E.g if there are 3 island of size 10 and 5 island of size 2 then ans would be 2.

My Solution
I solved it using set . interviewer pointed some mistake in my code. i tried to solve it but time was over. According to interviewer my approach was right but my code was 70-80% correct.(1-2 edge cases were missing).

I just want to discuss what can be the verdict. I am assuming it can be Lean No Hire / Lean Hire .

What do you think guyzz ?

Update : Got No hire in this round

Comments (6)