Better Pattern or not?

A question on HackerEarth is to find the berth of the coach.
Question Link

I found the pattern & solved this. This is my approach. But I am not satisfied by my logic even though it passes all testcases.
Please tell me any alternate approach.

I think this is the best approach.

1 Like

I tried another approach. I guess this would be satisfying :smiley:


        cout<<"Side Lower \n";
      else if(seat_number==8)
        cout<<"Side Upper \n";
      else if(seat_number%3==1)
        cout<<"Lower \n";
      else if(seat_number%3==2)
        cout<<"Middle \n";
        cout<<"Upper \n";


1 Like