Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
isaiahliu committed Jan 14, 2025
1 parent 8769138 commit 35e2f49
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/main/kotlin/p32xx/Problem3270.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
package p32xx

import util.expect
import java.util.*

fun main() {
class Solution {
fun generateKey(num1: Int, num2: Int, num3: Int): Int {
var nums = intArrayOf(num1, num2, num3)
var b = 1
var result = 0
val nums = LinkedList<Int>()
nums += num1
nums += num2
nums += num3

var result = 0
var b = 1
repeat(4) {
result += b * nums.minOf {
(it % 10).also {
it / 10
}
var min = 10
repeat(3) {
val num = nums.poll()

min = minOf(min, num % 10)

nums += num / 10
}

result += min * b
b *= 10
}

Expand Down

0 comments on commit 35e2f49

Please sign in to comment.