You can try “石子合并”.
ohh I thought you were asking general way to searching for problems duringcontests
absolutely no…
Yeah my bad:joy:
//20char limit
Dhananjay bhai, ,machaxx
Bhai you are great
5 star, huh!
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.