Google online interview question

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2024-11-25Added By Anonymous
Source: Link

Company: Google
Role: Software Engineer 3 (L4)
Interview Stage: Phone Screen
Location: unknown
Year: 2024

Original Post Content:

Hi All,

I gave Google interview in October 2024 for a Software Engineer 3 (L4) position. And this is the question I received.

Experience - 4 years

You are given a list of vote power and states:

votesPower = [1, 5, 7, 8, 9, 10, 20]
states = ["California", "Texas", "Florida", "Indiana", "Alaska", "Ohio", "Hawaii"]

And you have two candidates C1 and C2, you need to return a List of List of states that we can make in such an order that both candidates receive the same amount of votes.

Example: [["California", "Texas", "Florida", "Indiana", "Alaska"], ["Ohio", "Hawaii"]]
The list can have different combinations, you need to return all the lists of combinations.

What would be the optimal solution for this problem?

Comments