The source of the exact same problem as JULY19-Circular Merging

You can try “石子合并”. :neutral_face::neutral_face:

:thinking::thinking::thinking::thinking: ohh I thought you were asking general way to searching for problems duringcontests

1 Like

absolutely no…

Yeah my bad​:joy::joy::joy::joy:
//20char limit

Dhananjay bhai, ,machaxx

2 Likes

Bhai you are great
5 star, huh!:raised_hands::raised_hands:

2 Likes

bhai 5 star:astonished:

Hi can you please explain why this works ? I also read somewhere that to deal with ring you can break it and append entire array then solve the question. I don’t understand why that works either. Would appreciate if you could help me with this ! Thanks

Take example like
7 4 6 9 2 3

If you arrange it like 9 2 3 7 4 6, in any case last element would never want pair up with first element as there would always be better option of minimizing cost by pairing up with second last element or 2 3 7 4 6 9, in this case, first element would next want to pair up with last element as there would always be better option of minimizing cost by select second element. Hope it will help.