Skip to content

Commit

Permalink
Create 1189-maximum-number-of-balloons.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
a93a committed Jan 27, 2023
1 parent b1b28fc commit 06cc694
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions kotlin/1189-maximum-number-of-balloons.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution {
fun maxNumberOfBalloons(text: String): Int {
val map = IntArray(26)
text.forEach {
if(it in "balon") map[it - 'a']++
}
var min = Integer.MAX_VALUE
"balon".forEach {
if(map[it - 'a'] == 0) return 0
else if(it == 'l' || it == 'o') min = minOf(min, map[it-'a']/2)
else min = minOf(min, map[it-'a'])
}
return min
}
}

0 comments on commit 06cc694

Please sign in to comment.