mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-10 00:09:06 +01:00
go: remove unused parameter
Task: The Number of Beautiful Subsets Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
aa9e412aa4
commit
17095ea3b2
1 changed files with 5 additions and 5 deletions
|
@ -7,20 +7,20 @@ import (
|
||||||
func beautifulSubsets(nums []int, k int) int {
|
func beautifulSubsets(nums []int, k int) int {
|
||||||
seen := make(map[int]int)
|
seen := make(map[int]int)
|
||||||
|
|
||||||
var dfs func(int, int) int
|
var dfs func(int) int
|
||||||
dfs = func(lastNum, i int) int {
|
dfs = func(i int) int {
|
||||||
// BASE: Got to the end of the slice
|
// BASE: Got to the end of the slice
|
||||||
if i >= len(nums) {
|
if i >= len(nums) {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize with skipping the current number
|
// Initialize with skipping the current number
|
||||||
foundSubsets := dfs(lastNum, i+1)
|
foundSubsets := dfs(i + 1)
|
||||||
|
|
||||||
// Check if we can include the current number
|
// Check if we can include the current number
|
||||||
if seen[nums[i]-k] == 0 && seen[nums[i]+k] == 0 {
|
if seen[nums[i]-k] == 0 && seen[nums[i]+k] == 0 {
|
||||||
seen[nums[i]] += 1
|
seen[nums[i]] += 1
|
||||||
foundSubsets += dfs(nums[i], i+1)
|
foundSubsets += dfs(i + 1)
|
||||||
seen[nums[i]] -= 1
|
seen[nums[i]] -= 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,5 +28,5 @@ func beautifulSubsets(nums []int, k int) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
slices.Sort(nums)
|
slices.Sort(nums)
|
||||||
return dfs(nums[0]-k-1, 0) - 1
|
return dfs(0) - 1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue