Merge pull request #2785 from iYaovo/fix/0046-全排列

docs:补充0046Java代码的return语句
This commit is contained in:
程序员Carl
2024-10-28 09:37:02 +08:00
committed by GitHub

View File

@ -201,6 +201,7 @@ class Solution {
public void backtrack(int[] nums, LinkedList<Integer> path) { public void backtrack(int[] nums, LinkedList<Integer> path) {
if (path.size() == nums.length) { if (path.size() == nums.length) {
result.add(new ArrayList<>(path)); result.add(new ArrayList<>(path));
return;
} }
for (int i =0; i < nums.length; i++) { for (int i =0; i < nums.length; i++) {
// 如果path中已有则跳过 // 如果path中已有则跳过
@ -524,3 +525,4 @@ public class Solution
<a href="https://programmercarl.com/other/kstar.html" target="_blank"> <a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/> <img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a> </a>