Question: Josephus Algorithm problem in C++ Answers in C++ please. Josephus Highest grade: Editor Submitted Versions 1 - string Josephus (vector guests, int M) { 2
Josephus Algorithm problem in C++
Answers in C++ please.

Josephus Highest grade: Editor Submitted Versions 1 - string Josephus (vector guests, int M) { 2 int count(0); 3- do { 4 if (count > guests.size()-1) { 5 6 } 7 ) 8 } Problem Statement Josephus attended a party where they had a rather strange raffle. Everyone was to stand in a circle, and every oth person was to be eliminated until only one person was remaining, who won the lawnmower. Write the function Josephus, which takes as parameters a vector representing the N guests at the party in the order they line up for the raffle, and the integer M, giving which person will be eliminated at each turn. Your function should return a string giving the name of the winner of the raffle (the last person standing). Hint: While there is a mathematical solution, queue will be much more straightforward. Constraints N, the length of the vector guests, will be greater than 0 and less than 2,000. M will be greater than zero and less than 2,000. Examples 1. guests = {"Josephus", "Titus", "Simon", "Eleazar"} M = 3 Returns: "Josephus Counting every third person from Josephus (remember, they are in a circle), Simon is eliminated first. Skipping Eleazar and Josephus, Titus goes next. Skipping Eleazar and Josephus, we come back to Eleazar. Josephus, who cleverly suggested M = 3, comes out the winner! 2 guests = {"Bradford", "Rosette", "Ji", "Ashleigh", "Avery", "Lavonna", "Fredericka"} M = 2 Returns: "Fredericka" 3. guests = {"Tiffany", "Randy", "it", "Sharlene", "Marquerite", "Debra", "Pok", "Tanisha", M = 17 Result: "Debra" This problem and its writeup were inspired by the Josephus problem in Algorithms, 4th Edition, by Robert Sedgewick and Kevin Wayne. Submit