Skip to content

Commit

Permalink
LeetCode #90 'Subsets II'. Fix bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
eminencegrs committed Dec 11, 2024
1 parent 2c81f6d commit 6dafaed
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public static class Solution
public static IList<IList<int>> Subsets(int[] numbers)
{
var result = new List<IList<int>>();
Array.Sort(numbers);
Dfs(0, []);
return result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,34 @@ public static IEnumerable<object[]> TestData()
}
];

yield return
[
new[] { 2, 2, 1 },
new List<IList<int>>
{
new List<int> { 1, 2, 2 },
new List<int> { 1, 2 },
new List<int> { 1 },
new List<int> { 2, 2 },
new List<int> { 2 },
new List<int>()
}
];

yield return
[
new[] { 2, 1, 2 },
new List<IList<int>>
{
new List<int> { 1, 2, 2 },
new List<int> { 1, 2 },
new List<int> { 1 },
new List<int> { 2, 2 },
new List<int> { 2 },
new List<int>()
}
];

yield return
[
new[] { 1, 2, 3 },
Expand Down Expand Up @@ -97,5 +125,23 @@ public static IEnumerable<object[]> TestData()
new List<int>()
}
];

yield return
[
new[] { 4, 4, 4, 1, 4 },
new List<IList<int>>
{
new List<int> { 1, 4, 4, 4, 4 },
new List<int> { 1, 4, 4, 4 },
new List<int> { 1, 4, 4 },
new List<int> { 1, 4 },
new List<int> { 1 },
new List<int> { 4, 4, 4, 4 },
new List<int> { 4, 4, 4 },
new List<int> { 4, 4 },
new List<int> { 4 },
new List<int>()
}
];
}
}

0 comments on commit 6dafaed

Please sign in to comment.