Jobs
Interviews

Solve Coins and Game using C Language

Solve Coins and Game using C to enhance your skills with c coding practice , master coding concepts, and prepare for interviews with practical exercises and detailed solutions.

Coins and Game

Difficulty : Medium

Categories :

  • Backtracking

Given N coins and K people, each person can propose a distribution of coins. When a person proposes a distribution:

  • A vote occurs among all members
  • The proposer needs equal or more votes in favor to win
  • If proposer loses, they are eliminated and next person proposes
  • Each person wants maximum coins while ensuring they win the vote

Rules:

  • Proposals start from person 1
  • All people vote optimally knowing future possibilities
  • Tie in votes counts as a win for proposer

Constraints:

  • 1 ≤ N ≤ 109
  • 1 ≤ K ≤ 104
  • N ≥ K

Examples:

Input: N = 100, K = 2
Output: [100,0]
Explanation: Person 1 proposes all coins for themselves.
Votes will be 1-1 (tie), so they win.
Input: N = 100, K = 1
Output: [100]
Explanation: With only one person, they get all coins.

Coding works best on a laptop or desktop, with a keyboard and a wider editor. You can read the problem here and solve it there.

Problem Solving

Input

What You'll Find Here

Practical Challenges Solve coding problems that strengthen your understanding of C.

Step-by-Step Tutorials Learn how to write efficient and optimized code.

Career-Focused Skills Prepare for technical interviews with targeted exercises.

Choose from the following categories