Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
isaiahliu committed Dec 26, 2024
1 parent d92a22e commit 9ffe764
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/kotlin/p31xx/Problem3159.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package p31xx

import util.expect

fun main() {
class Solution {
fun occurrencesOfElement(nums: IntArray, queries: IntArray, x: Int): IntArray {
return nums.indices.filter { nums[it] == x }.let { indices ->
queries.map { indices.getOrNull(it - 1) ?: -1 }
}.toIntArray()
}
}

expect {
Solution().occurrencesOfElement(
intArrayOf(), intArrayOf(), 1
)
}
}

0 comments on commit 9ffe764

Please sign in to comment.