Optimal Seating Arrangement Algorithm