This commit is contained in:
kagura 2024-08-10 10:30:28 +08:00
parent beebc54755
commit a98623af75
3 changed files with 24 additions and 9 deletions

View file

@ -1,4 +1,4 @@
fun main() {
val t = Test763()
val t = Test560()
t.test()
}

View file

@ -1,8 +0,0 @@
class Test46 {
class Solution {
fun permute(nums: IntArray): List<List<Int>> {
val result = arrayOf(intArrayOf())
for (i in)
}
}
}

23
src/Test560.kt Normal file
View file

@ -0,0 +1,23 @@
class Test560 {
class Solution {
fun subarraySum(nums: IntArray, k: Int): Int {
var result = 0
for (i in nums.indices) {
var sum = 0
for (j in i..nums.lastIndex){
sum += nums[j]
if (sum == k){
result ++
}
}
}
return result
}
}
fun test(): Unit {
// println(Solution().subarraySum(intArrayOf(1,1,1),2))
// println(Solution().subarraySum(intArrayOf(1,2,3),3))
println(Solution().subarraySum(intArrayOf(1,-1,0),0))
}
}