Google online interview question

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2024-11-25Added By Anonymous
Source: Link
🧭 Experience: 4 years
✅ Outcome: unknown
💰 Compensation: unknown
📍 Location: unknown
🏢 Company: Google
🎓 Education: unknown
🎁 Benefits: unknown
📅 Offer Date: unknown

Hi All,
I gave google interview in October 2024 for a Software Engineer 3(L4) position. And this is the questions 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