๐ฏ
This file contains hidden or 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(answers: IntArray): IntArray { | |
val student1 = intArrayOf(1, 2, 3, 4, 5) | |
val student2 = intArrayOf(2, 1, 2, 3, 2, 4, 2, 5) | |
val student3 = intArrayOf(3, 3, 1, 1, 2, 2, 4, 4, 5, 5) | |
val results = mutableListOf(0, 0, 0) | |
var a = 0 | |
var b = 0 | |
var c = 0 | |
This file contains hidden or 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): Int { | |
var sum = 0 | |
var number = n | |
while(number%10 != 0 || number > 0){ | |
sum += number%10 | |
number = number/10 | |
} | |
return sum | |
} |
This file contains hidden or 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 { | |
return when(s.length % 2){ | |
0 -> s.subSequence((s.length / 2) - 1, (s.length / 2) + 1).toString() | |
else -> s.subSequence((s.length-1) / 2, (s.length-1) / 2 + 1).toString() | |
} | |
} | |
} |
This file contains hidden or 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): Int = s.toInt() | |
} |
This file contains hidden or 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 { | |
if(a == b) return b.toLong() | |
val list = listOf(a, b).sorted() | |
return (list[0]..list[1]).map { it.toLong() }.sum() | |
} | |
} |
This file contains hidden or 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): Boolean { | |
val chars = s.toCharArray() | |
return chars.all{ it.isDigit() } && (chars.size == 4 || chars.size == 6) | |
} | |
} |
This file contains hidden or 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(array: IntArray, commands: Array<IntArray>) { | |
fun solution(array: IntArray, commands: Array<IntArray>): IntArray { | |
var answer: IntArray | |
answer = commands.map { | |
val i = it[0]-1 | |
val j = it[1] | |
val k = it[2]-1 | |
val subArr = array.toMutableList().subList(i, j).sortedBy { it } |