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
fun countingSort(arr: Array<Int>): Array<Int> = | |
IntArray(100) { 0 } | |
.apply { | |
arr.forEach { this[it]++ } | |
} | |
.toTypedArray() | |
fun main(args: Array<String>) { | |
val n = readln().trim().toInt() |
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
import kotlin.* | |
import kotlin.math.absoluteValue | |
fun diagonalDifference(arr: Array<Array<Int>>): Int { | |
var sum = 0 | |
for (i in arr.indices) { | |
sum += arr[i][i] | |
sum -= arr[i][arr.lastIndex - i] | |
} | |
return sum.absoluteValue |
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
import kotlin.* | |
fun lonelyinteger(a: Array<Int>): Int = | |
a.groupingBy { it } | |
.eachCount() | |
.filterValues { it == 1 } | |
.entries | |
.single() | |
.key |
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
import java.time.format.DateTimeFormatter | |
fun timeConversion(s: String): String { | |
val format = DateTimeFormatter.ofPattern("hh:mm:ssa") | |
val time = format.parse(s) | |
return DateTimeFormatter.ofPattern("HH:mm:ss").format(time) | |
} | |
fun main(args: Array<String>) { | |
val s = readln() |
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
fun miniMaxSum(arr: Array<Int>) { | |
val sorted = arr.map(Int::toLong).sorted() | |
println("${sorted.dropLast(1).sum()} ${sorted.drop(1).sum()}") | |
} | |
fun main(args: Array<String>) { | |
val arr = readln().trimEnd() | |
.split(" ") | |
.map { it.toInt() } | |
.toTypedArray() |
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
fun main() { | |
val target = readln().toInt() | |
findSubset( | |
initialValue = 1, | |
targetValue = target, | |
/* | |
방문 여부 확인 그래프. | |
target + 1개의 인덱스를 가진 리스트 생성, 초기값 지정(초기값 상관 없음) | |
인덱스 번호는 탐색한 숫자들을 나타내기 때문에 인덱스 0은 사용하지 않는다. |
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
/** | |
* copied from jetcaster, android compose samples | |
* https://github.com/android/compose-samples/blob/main/Jetcaster/app/src/main/java/com/example/jetcaster/ui/JetcasterAppState.kt | |
*/ | |
@Suppress("DEPRECATION") | |
fun checkIfOnline(): Boolean { | |
val cm = ContextCompat.getSystemService(context, ConnectivityManager::class.java) | |
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
val capabilities = cm?.getNetworkCapabilities(cm.activeNetwork) ?: return false |
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
Gradle Version Catalog | buildSrc | ||
---|---|---|---|
버전 검색 | 자동 | 수동 | |
버전 번호 변경 후 Rebuild | 버전의 영향을 받는 모듈만 | 프로젝트의 모든 모듈 |
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
@DormDeprecated | |
fun Modifier.dormShadow( | |
color: Color, | |
alpha: Float = 0.2f, | |
borderRadius: Dp = 0.dp, | |
shadowRadius: Dp = 10.dp, | |
offsetY: Dp = 0.dp, | |
offsetX: Dp = 0.dp, | |
) = this.drawBehind { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
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
@DormDeprecated | |
fun Modifier.dormShadow( | |
color: Color, | |
alpha: Float = 0.2f, | |
borderRadius: Dp = 0.dp, | |
shadowRadius: Dp = 10.dp, | |
offsetY: Dp = 0.dp, | |
offsetX: Dp = 0.dp, | |
) = this.drawBehind { | |
val transparentColor = |