This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
fun solution(s: String): String { | |
val chars = s.toCharArray() | |
val result = chars.sortedWith(Comparator { o1, o2 -> o2 - o1 }) | |
return result.joinToString("") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
fun solution(strings: Array<String>, n: Int): Array<String> { | |
var i = strings.size - 1 | |
while (i > 0) { | |
var j = 0 | |
while (j < i) { | |
var temp: String | |
if (strings[j][n] > strings[j + 1][n]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
var printOrders = arrayListOf<Int>() | |
var waitings = arrayListOf<Pair<Int, Int>>() | |
fun solution(priorities: IntArray, location: Int): Int { | |
for ((i, v) in priorities.withIndex()) { | |
waitings.add(Pair(i, v)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
fun solution(N: Int, number: Int): Int { | |
val f = f(N, number) | |
if (f > 8){ | |
return -1 | |
} | |
return f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
fun solution(a: Int, b: Int): Long { | |
var answer = 0L | |
if (a == b){ | |
return a.toLong() | |
} | |
var min = Integer.min(a,b) | |
var max = Integer.max(a,b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
fun solution(arr: IntArray, divisor: Int): IntArray { | |
var answer = arrayListOf<Int>() | |
for (ar in arr){ | |
if (ar % divisor == 0){ | |
answer.add(ar) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
fun solution(record: Array<String>): Array<String> { | |
var answer = mutableListOf<String>() | |
var nickNameMap = mutableMapOf<String, String>() | |
var history = mutableListOf<Pair<String, String>>() | |
for (line in record) { | |
val tokens = line.split(" ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
fun solution(s: String): String { | |
val length = s.length | |
return if (length % 2 == 0){ | |
s.substring(length/2-1, length/2+1) | |
}else{ | |
s.substring(length/2, length/2+1) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
fun solution(N: Int, stages: IntArray): IntArray { | |
var stageCountMap = mutableMapOf<Int, Int>() | |
var failRateMap = mutableMapOf<Int, Float>() | |
var remained = stages.size | |
for (stage in stages){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
fun solution(record: Array<String>): Array<String> { | |
var answer = mutableListOf<String>() | |
var nickNameMap = mutableMapOf<String, String>() | |
var history = mutableListOf<Pair<String, String>>() | |
for (line in record) { | |
val tokens = line.split(" ") |