• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

太麻烦了只好用追踪

public list integer four sum(int[]nums,int target) {

ListListInteger ans=new ArrayListListInteger();

if(nums==null || nums.length==0)返回美国国家标准(American National Standards的缩写)

list integer list=new ArrayList();

数组。排序(nums);

getSum(nums,0,target,ans,list,0);

返回美国国家标准(American National Standards的缩写)

}

private void getSum(int[] nums,int sum,int target,ListListInteger ans,ListInteger list,int pos){

if(list.size()==4 sum==target!答案包含(列表)){

ans。add(new ArrayList(list));返回;

}else if(list.size()==4)返回;

for(int I=pos;i nums.lengthi)

if(numsnums[nums。长度-1]*(3-列表。size())总和目标)继续;

if(nums*(4-list。size())总和目标)返回;

列表。add(nums);

getSum(nums,sum nums,target,ans,list,I 1);

列表。移除(列表。size()-1);

}

}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now