I was reading through a problem and was trying to solve this problem.

> 
> You've invited N people over for dinner. Let's say 4.
> 
> 
> You have a circular dinner table and you wish to seat everyone around
>  it. Unfortunately, not all of your friends are friends with each
>  other, but you'd like to seat everyone optimally so that as many
>  people as possible are seated next to people they consider friends and
>  not enemies. 
> 
> 
> You've charted everyone's friendships and hatreds in a matrix of size
>  NxN and represented friendships with the integer 1, hatreds with -1,
>  and sheer indifference with 0.
> 
> 
> 

```
[[ 0, 1, 1, 1, 1],    ← yes you like all your friends
 [-1, 0, 1,-1, 0],
 [-1, 1, 0, 1, 0],
 [ 1, 1, 1, 0,-1],
 [ 1, 0, 0,-1, 0]]

```

**Question:**

> 
> -> Write a Javascript method that computes an optimal seating arrangement as an Array, e.g. [0,4,2,1,3], for a given input matrix. (assuming indexes 0
>  and N-1 are seated adjacently). What is the time complexity for the
>  solution? Add thoughts on possible optimizations.
> 
> 
> 

I've tried solving this manually however, I didn't understand the question's example [0,4,2,1,3] for the given input matrix.

**Can someone Enlighten me?**

How did he/she come up with [0,4,2,1,3]?

Thanks and very much appreciate your time.