What does dp[i][j] denote in TSP problem, DP with bitmasks

The link to my code with the commented sample input is here

I cannot figure out what does dp[i][j] signify.

It would be great if you could explain this to me with the help of the entries at dp[29][2], dp[29][3], dp[29][4].

I have no clue why they are set to 300,101,1100 respectively.

@devpratik it signifies the cost to visit all unvisited cities to complete the tour(given by mask-i), starting from city j.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.