From 8764cf78ca0be5ddfe65d5c712492a4607e2fc12 Mon Sep 17 00:00:00 2001 From: isaiahliu Date: Mon, 30 Dec 2024 11:20:17 +0800 Subject: [PATCH] 1 --- src/main/kotlin/p30xx/Problem3046.kt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/kotlin/p30xx/Problem3046.kt diff --git a/src/main/kotlin/p30xx/Problem3046.kt b/src/main/kotlin/p30xx/Problem3046.kt new file mode 100644 index 00000000..d219c0e4 --- /dev/null +++ b/src/main/kotlin/p30xx/Problem3046.kt @@ -0,0 +1,20 @@ +package p30xx + +import util.expect + +fun main() { + class Solution { + fun isPossibleToSplit(nums: IntArray): Boolean { + val set1 = hashSetOf() + val set2 = hashSetOf() + + return nums.all { set1.add(it) || set2.add(it) } + } + } + + expect { + Solution().isPossibleToSplit( + intArrayOf(1, 1, 0, 0, 0, 1, 1, 0, 0, 1), 3 + ) + } +}