• 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

标题描述

给你一个只包含正整数的非空数组nums。请判断这个数组是否可以分成两个子集,使得两个子集的元素之和相等。

示例1:

输入:nums=[1,5,11,5]

输出:真

说明:数组可以分为[1,5,5]和[11]。

示例2:

输入:nums=[1,2,3,5]

输出:假

说明:一个数组不能分成两个元素和相等的子集。

方法流程:

1.把问题变成,对于一个数组,数组中n个元素的和是否以sum存在?

2.一维dp无法表达这个问题。二维DP,dp[j]用来表示数组中前I个元素的任意组合是否能组成j。

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