Initially I thought that this is stable marriage problem with ties, did a bit of research but finally gave up.
Your solution fails for this test case-
1
24
A 12
A 9
A 9
A 9
B 12
B 12
B 9
B 9
B 9
B 9
C 12
C 12
C 3
C 3
C 3
C 6
C 6
D 3
D 3
D 3
D 3
D 6
D 6
D 6
Expected output-
825
825
Your programās output-
925
925
Hope this helps
If you donāt know the NQueens problem, Iāll first advice you to study that and then try to understand my solution.
Try
Test case
1
4
A 6
C 6
C 6
C 9
Try
Test Case
1
2
B 9
D 9
I am familiar the NQueens approach. I was finding difficult to understand your implementation. Which is why I asked if you could please elaborate a bitā¦
WTF mahn!!! Respect = infinity;
when my code was long (according to noob me) I thought there ought to be some other solution and stopped coding.
Now I know what it takes for an AC;
Smart work is better than hard work
Should have done it easier but couldnāt think of any other solution
Oh! god, Silly Mistake! the ticket variable was to be reinitialized for every best_choice and I forgot about it. By the way thanks for your time.
Yeahā¦I know .
I was pointing out your dedication.
Oh, Thank you mate. One combination messed it up. AC now
I am only getting 30 points,can you fix it.
Can someone please provide a JAVA implementation of this, as in JAVA we donāt have any nextPermutation kinda function, so its becoming lil bit comlicated for me to go through, kindly help if any one can traslate the same implementation to simplest efficient JAVA codeā¦
Thanks in advanceā¦
Try this test case-
Test case
1
10
B 12
C 3
A 6
D 12
A 12
C 6
A 9
D 3
C 12
A 3
Ans- 250
Try
Test case
1
4
A 12
A 9
B 6
C 9
Could you fix the link? It doesnāt point to any submission.
The recursive method works in pretty much every language and it is simple enough. Moreover, it can be easily extended (find all arrays with integers from 1 to n where each value can appear at most twice).
thanks a lot:+1:
Can we use Hungarian Algorithm to solve this problem?