Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加注释 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Solution3.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public List<Integer> largestDivisibleSubset(int[] nums) {
int maxSize = 1; // 最大子集的大小,最初是 1
int maxValIndex = 0; // 用来记录最大子集的末尾元素的索引

// 递推公式:dp[i] = max(dp[i], dp[j] + 1) if nums[i] % nums[j] == 0
for (int i = 1; i < len; i++) { // 从第二个元素开始遍历
for (int j = 0; j < i; j++) { // 比较每个元素 nums[i] 和之前的元素 nums[j]
if (nums[i] % nums[j] == 0) { // 如果 nums[i] 能被 nums[j] 整除
Expand Down