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
| // java 8 이상에서 현재 시간에 맞는 각 타임존 별 시간 얻기 | |
| val pattern = DateTimeFormatter.ofPattern("HH:mm:ss") | |
| val seoul = ZonedDateTime.now() | |
| println(seoul.format(pattern)) | |
| val utc = seoul.withZoneSameInstant(ZoneOffset.UTC) | |
| println(utc.format(pattern)) | |
| val vancouver = utc.withZoneSameInstant(ZoneId.of("America/Vancouver")) |
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
| import java.io.* | |
| import java.math.* | |
| import java.security.* | |
| import java.text.* | |
| import java.util.* | |
| import java.util.concurrent.* | |
| import java.util.function.* | |
| import java.util.regex.* | |
| import java.util.stream.* | |
| import kotlin.collections.* |
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
| fun pickingNumbers(a: Array<Int>): Int { | |
| var ret = Int.MIN_VALUE | |
| val map = hashMapOf<Int, Int>() | |
| a.forEach { i -> | |
| map[i] = a.filter { it == i }.size | |
| } | |
| for (i in map.keys) { | |
| val value = map[i]!!.plus(map.getOrDefault(i - 1, 0)) | |
| if (value > ret) { |
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
| val Int.dp: Int | |
| get() = (this / Resources.getSystem().displayMetrics.density).toInt() | |
| val Int.px: Int | |
| get() = (this * Resources.getSystem().displayMetrics.density).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
| fun main() { | |
| println(maxSubArray(intArrayOf(-2,1,-3,4,-1,2,1,-5,4))) | |
| } | |
| fun maxSubArray(nums: IntArray): Int { | |
| var currentMax = nums[0] | |
| var max = nums[0] | |
| for (i in 1 until nums.size) { | |
| currentMax = Math.max(nums[i], nums[i]+currentMax) |
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(arrayParam: IntArray, targetParam: Int): IntArray { | |
| val map = mutableMapOf<Int, Int>() | |
| arrayParam.forEachIndexed { index, i -> | |
| val diff = targetParam - i | |
| map[diff]?.let { | |
| return arrayOf(it, index).toIntArray() | |
| } | |
| map[i] = index | |
| } |
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
| fun main() { | |
| println(solution(intArrayOf(-6, -91, 1011, -100, 84, -22, 0, 1, 473))) | |
| } | |
| fun solution(A: IntArray): Int { | |
| val oneDigits = A.filter { it < 10 && it > -10 } | |
| var max = oneDigits[0] | |
| oneDigits.forEach { | |
| if (it > max) { | |
| max = it |
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
| fun main() { | |
| println(solution(28)) | |
| println(solution(734)) | |
| println(solution(1990)) | |
| println(solution(1000)) | |
| } | |
| fun solution(N: Int): Int { | |
| val target = sumOfDisassembledN(N) | |
| var n = N |
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
| fun main() { | |
| println(solution("azABaabza")) | |
| println(solution("ABcabbCa")) | |
| println(solution("azABaabza")) | |
| println(solution("CATattac")) | |
| println(solution("TacoCat")) | |
| println(solution("Madam")) | |
| println(solution("AcZCbaBz")) | |
| println(solution("aZABcabbCa")) | |
| } |
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
| fun main() { | |
| println(solution("azABaabza")) | |
| println(solution("ABcabbCa")) | |
| println(solution("azABaabza")) | |
| println(solution("CATattac")) | |
| println(solution("TacoCat")) | |
| println(solution("Madam")) | |
| println(solution("AcZCbaBz")) | |
| println(solution("aZABcabbCa")) | |
| } |
OlderNewer