Open Coderayush13 opened 1 year ago
Assign this to me Please.
Please assign this to me.
Hi @1dharode , Kindly please assign me this issue.
In this problem,There are N people standing in a circle waiting to be executed. The counting out begins at some point in the circle and proceeds around the circle in a fixed direction. In each step, a certain number of people are skipped and the next person is executed. The elimination proceeds around the circle (which is becoming smaller and smaller as the executed people are removed), until only the last person remains, who is given freedom.
Given the total number of persons N and a number k which indicates that k-1 persons are skipped and the kth person is killed in a circle. The task is to choose the person in the initial circle that survives.
Example:
Input: N = 7 and k = 3
Output: 4
Explanations: The persons at positions 3, 6, 2, 7, 5, and 1 are killed in order,
and the person at position 4 survives.
please assign this to me @Coderayush13
please assign this issue to me @Coderayush13 . I have also seen about this problem on numberphile and can provide a good solution for the same
@Coderayush13 please assign this task to me
Can you please assign this issue to me ?
In Josephus problem, n people are standing in a circle waiting to be executed and in every iteration, we kill the kth person and remove that person from the circle.
This procedure is repeated with the remaining people, starting with the (k+1)th person going in the same direction and killing the kth person, until only one person remains and is not killed.
We have to find the survivor position in the initial circle–given n the number of people standing in the circle initially and k the kth person to be executed.
JosephusProblem(n, k)– represents this problem.
JosephusProblem(8, 2)– 8 people are standing in a circle and in every iteration we kill the 2nd person.
First of all, the person at position 2 is killed, then the person at position 4 is killed, then the person at position 6 is killed then the person at position 8 is killed. , Then the persons at positions 3, 5, 7 are killed. So the person at position 1 survives.