• Home
  • About
    • Moon photo

      Moon

      개발자는 자고 싶다.

    • Learn More
    • Twitter
    • Facebook
    • Instagram
    • Github
    • Steam
  • Posts
    • All Posts
    • All Tags
  • Projects

백준 - 10809 알파벳 찾기

07 Jun 2022

Reading time ~1 minute

문제

10809 알파벳 찾기

screencapture

답

kotlin code

import java.util.*

fun main() {
    q10809()
}

fun q10809() = with(Scanner(System.`in`)) {
    val input = next();
    val inputs = input.toCharArray().map { it.code }

    for(alphabet in 'a'.code .. 'z'.code) {
        if(!inputs.contains(alphabet)) {
            print("-1 ")
            continue
        }

        for (index in inputs.indices) {
            if(alphabet == inputs[index]) {
                print("$index ")
                break
            }
        }
    }
}


baekjoonkotlin코틀린백준브론즈구현문자열 Share Tweet +1