2902 first try brute force solution, tests did not pass
This commit is contained in:
@@ -1,5 +1,30 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
func CountSubMultisets(nums []int, l int, r int) int {
|
func countSubMultisetsBrute(nums []int, l int, r int) int {
|
||||||
return 0
|
ln := len(nums)
|
||||||
|
count := 0
|
||||||
|
for i := 0; i < ln; i++ {
|
||||||
|
sum := nums[i]
|
||||||
|
if sum >= l && sum <= r {
|
||||||
|
count++
|
||||||
|
} else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for j := 0; j < ln; j++ {
|
||||||
|
if i == j {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
sum += nums[j]
|
||||||
|
if sum >= l && sum <= r {
|
||||||
|
count++
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
func CountSubMultisets(nums []int, l int, r int) int {
|
||||||
|
return countSubMultisetsBrute(nums, l, r)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user