LeetCode 416.分割等和子集 最近刚开始学背包问题,做到了这个示例题。 问题分析 给定一个正整数数组 nums,判断是否能将其分割成两个和相等的子集。这个问题本质上等价于:是否存在一个子集,其元素和等于数组总和的一半。解决这个问题的关键在于将其转化为经典的 0-1背包问题。 二维动态规划解法 状态定义 定义二维数组 dp[i][j],表示…
题目 https://leetcode.com/problems/linked-list-cycle/ Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked li…