Hot Potato Game

Medium Queue: Applications PRO
🔒 Login to Unlock

Problem Statement

Write a C program to simulate the Hot Potato game using a queue and find the winning person’s position.

Input Format

Two space-separated integers: n (number of people) and k (passes count).

Output Format

Print the winner's 1-indexed position.

Constraints

1 <= n <= 30, 1 <= k <= 10

Sample Input

7 3

Sample Output

4

Explanation

Enqueue n people into a queue. Rotate the queue k times, dequeue the eliminated person, and repeat until one person remains.

Starter Code

#include <stdio.h>
#include <stdlib.h>

int main() {
    int n, k;
    if (scanf("%d %d", &n, &k) == 2) {
        // Write your code here to simulate Hot Potato game using queue
    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used