diff --git a/README.md b/README.md index ffc06b674..47e5b43b3 100644 --- a/README.md +++ b/README.md @@ -381,7 +381,7 @@ If you would like to have collaborator permissions on the repo to merge your own [0134 - Gas Station](https://leetcode.com/problems/gas-station/) |
[✔️](c%2F0134-gas-station.c)
|
[✔️](cpp%2F0134-gas-station.cpp)
|
[✔️](csharp%2F0134-gas-station.cs)
|
|
[✔️](go%2F0134-gas-station.go)
|
[✔️](java%2F0134-gas-station.java)
|
[✔️](javascript%2F0134-gas-station.js)
|
[✔️](kotlin%2F0134-gas-station.kt)
|
[✔️](python%2F0134-gas-station.py)
|
[✔️](ruby%2F0134-gas-station.rb)
|
|
|
[✔️](swift%2F0134-gas-station.swift)
|
[✔️](typescript%2F0134-gas-station.ts)
[0846 - Hand of Straights](https://leetcode.com/problems/hand-of-straights/) |
|
[✔️](cpp%2F0846-hand-of-straights.cpp)
|
[✔️](csharp%2F0846-hand-of-straights.cs)
|
|
[✔️](go%2F0846-hand-of-straights.go)
|
[✔️](java%2F0846-hand-of-straights.java)
|
[✔️](javascript%2F0846-hand-of-straights.js)
|
[✔️](kotlin%2F0846-hand-of-straights.kt)
|
[✔️](python%2F0846-hand-of-straights.py)
|
[✔️](ruby%2F0846-hand-of-straights.rb)
|
|
|
|
[✔️](typescript%2F0846-hand-of-straights.ts)
[1423 - Maximum Points You Can Obtain From Cards](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards/) |
|
|
[✔️](csharp%2F1423-Maximum-Points-You-Can-Obtain-from-Cards.cs)
|
|
|
|
|
[✔️](kotlin%2F1423-maximum-points-you-can-obtain-from-cards.kt)
|
|
|
|
|
|
-[1899 - Merge Triplets to Form Target Triplet](https://leetcode.com/problems/merge-triplets-to-form-target-triplet/) |
|
[✔️](cpp%2F1899-merge-triplets-to-form-target-triplet.cpp)
|
[✔️](csharp%2F1899-Merge-Triplets-to-Form-Target-Triplet.cs)
|
|
|
[✔️](java%2F1899-merge-triplets-to-form-target-triplet.java)
|
[✔️](javascript%2F1899-merge-triplets-to-form-target-triplet.js)
|
|
[✔️](python%2F1899-merge-triplets-to-form-target-triplet.py)
|
[✔️](ruby%2F1899-merge-triplets-to-form-target-triplet.rb)
|
|
|
[✔️](swift%2F1899-Merge-Triplets-To-Form-Target-Triplet.swift)
|
[✔️](typescript%2F1899-Merge-Triplets-to-Form-Target-Triplet.ts)
+[1899 - Merge Triplets to Form Target Triplet](https://leetcode.com/problems/merge-triplets-to-form-target-triplet/) |
|
[✔️](cpp%2F1899-merge-triplets-to-form-target-triplet.cpp)
|
[✔️](csharp%2F1899-Merge-Triplets-to-Form-Target-Triplet.cs)
|
|
|
[✔️](java%2F1899-merge-triplets-to-form-target-triplet.java)
|
[✔️](javascript%2F1899-merge-triplets-to-form-target-triplet.js)
|
[✔️](kotlin%2F1899-merge-triplets-to-form-target-triplet.kt)
|
[✔️](python%2F1899-merge-triplets-to-form-target-triplet.py)
|
[✔️](ruby%2F1899-merge-triplets-to-form-target-triplet.rb)
|
|
|
[✔️](swift%2F1899-Merge-Triplets-To-Form-Target-Triplet.swift)
|
[✔️](typescript%2F1899-Merge-Triplets-to-Form-Target-Triplet.ts)
[0763 - Partition Labels](https://leetcode.com/problems/partition-labels/) |
|
[✔️](cpp%2F0763-partition-labels.cpp)
|
[✔️](csharp%2F0763-partition-labels.cs)
|
|
[✔️](go%2F0763-partition-labels.go)
|
[✔️](java%2F0763-partition-labels.java)
|
[✔️](javascript%2F0763-partition-labels.js)
|
|
[✔️](python%2F0763-partition-labels.py)
|
[✔️](ruby%2F0763-partition-labels.rb)
|
|
|
|
[0678 - Valid Parenthesis String](https://leetcode.com/problems/valid-parenthesis-string/) |
[✔️](c%2F0678-valid-parenthesis-string.c)
|
[✔️](cpp%2F0678-valid-parenthesis-string.cpp)
|
[✔️](csharp%2F0678-valid-parenthesis-string.cs)
|
|
|
[✔️](java%2F0678-valid-parenthesis-string.java)
|
[✔️](javascript%2F0678-valid-parenthesis-string.js)
|
|
[✔️](python%2F0678-valid-parenthesis-string.py)
|
|
|
|
|
[✔️](typescript%2F0678-valid-parenthesis-string.ts)
[1921 - Eliminate Maximum Number of Monsters](https://leetcode.com/problems/eliminate-maximum-number-of-monsters/) |
|
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/kotlin/1899-merge-triplets-to-form-target-triplet.kt b/kotlin/1899-merge-triplets-to-form-target-triplet.kt new file mode 100644 index 000000000..791c9e02e --- /dev/null +++ b/kotlin/1899-merge-triplets-to-form-target-triplet.kt @@ -0,0 +1,15 @@ +class Solution { + fun mergeTriplets(triplets: Array, target: IntArray): Boolean { + val filteredTriplets = triplets.filter { triplet -> + triplet[0] <= target[0] && triplet[1] <= target[1] && triplet[2] <= target[2] + } + if (filteredTriplets.isEmpty()) return false + val matches = booleanArrayOf(false, false, false) + filteredTriplets.forEach { (x, y, z) -> + matches[0] = matches[0] || x == target[0] + matches[1] = matches[1] || y == target[1] + matches[2] = matches[2] || z == target[2] + } + return matches.all { it == true } + } +} \ No newline at end of file