Max Points from Gem Gathering

Maximize Points from Gem Gathering

You and your partner are explorers traveling through various islands collecting rare gems. Each island contains a certain number of gems, given by the array gems[i]. You always collect exactly take1 gems from each island when it's your turn. Your partner, however, has two options when it's their turn:
Collect exactly take2 gems from the current island, or skip their turn completely (no gems collected).
Your partner can only skip their turn a limited number of times, represented by skips.
A point is earned only if you are the one to collect the last gem from an island. After an island has no gems left, you and your partner move on to the next island.
Implement a function to maximize the total number of points earned.

Constraints
1 <= len(gems) <= 1000
1 <= gems[i] <= 10^4
1 <= take1, take2 <= 100
0 <= skips <= len(gems)

Example
Input:
gems = [8, 12, 5], take1 = 3, take2 = 4, skips = 1
Output:
2

Explanation:
- Island 1 (8 gems): You(3), Partner(4), You(1) ✔ (You collect last gem, +1 point)
- Island 2 (12 gems): You(3), Partner(skip), You(3), Partner(4), You(2) ✔ (+1 point)
- Island 3 (5 gems): You(3), Partner(2) ✘ (Partner collects last gem, no point)
Total points = 2.



Get one-to-one training from Google Facebook engineers

Top-notch Professionals

Learn from Facebook and Google senior engineers interviewed 100+ candidates.
Most recent interview questions and system design topics gathered from aonecode alumnus.
One-to-one online classes. Get feedbacks from real interviewers.

Customized Private Class

Already a coding expert? - Advance straight to hard interview topics of your interest.
New to the ground? - Develop basic coding skills with your own designated mentor.
Days before interview? - Focus on most important problems in target company question bank.