Last man standing , used circular linked list
<p><strong>Question :</strong> A company hiring candidates, makes them sit in a circle.
They select every second candidate and he leaves the circle (thus circle keeps getting    smaller), till only 1 is left.
So, if there are 5 people, it'll be like :-</p>

<pre><code>1 2 3 4 5
1 3 4 5    (2 is selected)
1 3 5      (4 is selected)
3 5        (1 is selected)
3          (3 is left, does'nt get the job!)
</code></pre>

<p>Jhon an oversmart guy doesn't want to be a part of this spiteful company.</p>

<p>Where does he stand if he knows that there are 560 people in total.
<strong>Ans :</strong> I tried to make a program where you enter n(number of candidates)
 and it'll print the value of the one seat that will go unselected.</p>

<p>I Used circular linked list and deletion.</p>

<p>Please bear with me , as i am fairly new to coding .</p>

<p><strong>My program works for inputs 2, 4, 8, 16, 32, 64 and so on as ans in all these is 1.
But any other input and it's not working.</strong></p>

<pre><code>#include &lt;iostream&gt;

using namespace std;

struct node
{
    node* ptr;
    int data;
}start;


int main()
{
    node *start=NULL;
    int n;
    cout&lt;&lt;"Enter the number of students : ";
    cin&gt;&gt;n;

   node *temp=new node;
   temp-&gt;data=1;
   temp-&gt;ptr=NULL;
   start=temp;
   for(int x=2;x&lt;=n;x++)
   {
       node* temp1=new node;
       temp1-&gt;data=x;
       temp-&gt;ptr=temp1;
       temp1-&gt;ptr=start;
       temp=temp1;

   }
   node* temp2=start;
   do
   {
       cout&lt;&lt;temp2-&gt;data&lt;&lt;" ";
       temp2=temp2-&gt;ptr;
   }while(temp2!=start);
   cout&lt;&lt;endl;


   //delete bigins here

   temp2=start;
   node* temp3=temp2-&gt;ptr;

   do
   {
        temp2-&gt;ptr=temp3-&gt;ptr;
        temp3-&gt;ptr=NULL;
        delete temp3;
        temp2=temp2-&gt;ptr;
        temp3=temp2-&gt;ptr;


   }while(temp2-&gt;ptr!=start);

    temp2=start;
   do
   {
       cout&lt;&lt;temp2-&gt;data&lt;&lt;" ";
       temp2=temp2-&gt;ptr;
   }while(temp2!=temp3);
   cout&lt;&lt;endl;
}
</code></pre>
