Google Interview experience
2 rounds over 4 weeks. No offer, meh experience.
Quick chat with the recruiter about my background and the role that I applied for and what the next steps would be
Was asked to implement the Allocate Minimum Number of Pages from N books to M students problem. I wasn't able to implement it fully in time
Problem:
You are given N books, where each book has a certain number of pages. These N books need to be distributed among M students such that each student gets at least one book, and the maximum number of pages assigned to a student is minimized.
Catch: Each student can only read books that are next to each other (in a contiguous block).
Example:
Input:
N = 4 (Number of books)
M = 2 (Number of students)
Pages = [12, 34, 67, 90] (Each number represents how many pages are in a book)
Output:
113 (the smallest possible number of pages that the student with the most pages has to read)
One possible way to split the books is:
Student 1: [12, 34, 67] (Total = 113 pages)
Student 2: [90] (Total = 90 pages)
Approach:
Binary Search: Use binary search to find the minimum possible value of the maximum number of pages a student will have to read.
Greedy Check: For a given maximum number of pages (mid), check if it’s possible to distribute the books such that no student reads more than mid pages. This involves a greedy approach where you try to allocate books to students and see if you can do it within the given mid value.
Got a call from the recruiter that they won't be moving forward
Know someone interviewing at Google? Pass it on.
Same company, different candidates.
Share yours while it’s fresh. It takes five minutes, it’s anonymous, and it will help future candidates.