n cube solution, leveraging 2sum

simpler code