Allowed R6 · Within policy
{
"slug": "coin-change-ways",
"title": "Coin Change Ways",
"difficulty": "medium",
"tags": [
"coding",
"oa",
"swe",
"intern"
],
"is_free": true,
"locked": false,
"frequency": 0.667,
"last_reported_at": "2026-09-09T12:56:14.966829Z",
"url": "https://www.mokabla.com/en/c/microsoft/coin-change-ways",
"agent": {
"page": "https://www.mokabla.com/agent/en/c/microsoft/coin-change-ways",
"question": "https://www.mokabla.com/agent/_call/get_question?company=microsoft&question=coin-change-ways"
},
"company": {
"slug": "microsoft",
"name_en": "Microsoft Egypt (ATLC)"
},
"body_md": "## Problem\nYou are given a list of coin denominations and a target `amount`. Each denomination is available in unlimited supply. Count how many **distinct combinations** of coins add up exactly to `amount`. Order does not matter: `{2, 1}` and `{1, 2}` are the same combination.\n\n## Examples\n**Example 1**, `coins = [1, 2, 5]`, `amount = 5` → `4`\nThe combinations are `{5}`, `{2, 2, 1}`, `{2, 1, 1, 1}` and `{1, 1, 1, 1, 1}`.\n\n**Example 2**, `coins = [2]`, `amount = 3` → `0`\nNo way to make an odd amount from 2s.\n\n**Edge**, `amount = 0` → `1` (the empty combination).\n\n## Constraints\n- `1 <= len(coins) <= 300`, `1 <= coin <= 5000`, denominations are distinct.\n- `0 <= amount <= 5000`.\n- The answer can be large; return it modulo `10^9 + 7` in the OA version.\n\n## What they look for\nA 1-D DP table `ways[x]` where the **outer loop is over coins** and the inner loop is over amounts. Swapping the loops counts ordered sequences instead of combinations, and that is the single most common wrong answer we see. I will ask you to explain, with the `[1, 2]` / `amount = 3` case, why the loop order matters. The recursive version with memoisation is acceptable if you can state its complexity.",
"follow_ups_md": "- Minimum number of coins instead of number of ways.\n- Each coin can be used at most once.\n- Reconstruct one of the combinations.",
"access": "Question bodies are paid content: a person buys 30 days of access per company (200 EGP or 200 points) in the human app. Agents get titles, tags and difficulty; bodies only for free questions."
}