This recent problem Bank Cooperation, from Heist is solved using bit manipulation in editorial but i think it is solvable by my approach too.
I thought of all 8 items as nodes in graph, where the paired up elements will form one component, now in components we cannot take neighbouring nodes, as they cant be put together. I found the maximum value that we can take from a component by doing modified dfs, and then added the maximum values of all the components.
I have thought of many cases but cant figure out why its wrong, please help…
You are complicating things a bit. All you gotta do is generate all subsets of 8 elements and check the subsets which are valid. If a subset is valid, note down its sum , and finally output the max. sum from all the valid-subsets.
To generate all subsets of given 8-elements, you can check Google/Gfg.