从链接列表中删除总和等于零的元素 [英] remove elements from link list whose sum equals to zero
本文介绍了从链接列表中删除总和等于零的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给出一个链表形式的列表,我必须取消所有总和为0(零)的资源,然后返回剩余的列表。
Given a list in form of linked list, I have to canceled out all the resources whose sum up to 0(Zero) and return the remaining list.
就像
6 -6 3 2 -5 4 returns 4
8 10 4 -1 -3 return 8 10
我只需要算法即可解决此问题。
I only need algorithm to solve this question.
推荐答案
这实际上是经典的子集和问题,它是NP完全的
this is actually the classic subset sum problem which is NP-complete
请参见 Wiki 或在Google上搜索有关该文章
see on wiki or google it to see articles about that
这篇关于从链接列表中删除总和等于零的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文