알고리즘34 leetcode] Single Number / Kotlin int 배열에서 한 값 빼고 중복으로 들어있는데중복이 아닌 값 리턴하는 문제. 전체 돌면서 같은거 없으면 그 값 리턴한다.class Solution { fun singleNumber(nums: IntArray): Int { var ans = 0 for(i in 0 until nums.size) { var isSingle = true for(j in 0 until nums.size) { if(i == j) continue if(nums[i] == nums[j]) isSi.. 2024. 10. 16. leetcode] Rotate Array / Kotlin https://leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/646/ class Solution { fun rotate(nums: IntArray, k: Int): Unit { // 이동할 위치 계산 val rotation = k % nums.size // 새로운 배열에 이동된 값 저장 val arr = IntArray(nums.size) for(i in nums.indices) { arr[(i+rotation) % nums.size] = nums[i] } //.. 2024. 10. 16. 79] 프로그래머스 a와 b 출력하기 kotlin fun main(args: Array) { val (a, b) = readLine()!!.split(' ').map(String::toInt) println("a = $a") println("b = $b") } https://postiveemblem.tistory.com/164 [Kotlin][5]코틀린 readline()과 자료형 변환 방법 안녕하세요. 오늘은 저번 타이머 함수 사용법에 이어서 readline()을 이용해 사용자에게 입력받는 법을 알아보려고 합니다. 또 입력 받은 모든 값을 스트링 값으로 반환하는 readline()을 어떻게 하면 postiveemblem.tistory.com 2023. 10. 5. 68] 프로그래머스 세균 증식 Kotlin https://school.programmers.co.kr/learn/courses/30/lessons/120910 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import kotlin.math.pow class Solution { fun solution(n: Int, t: Int): Int { var answer: Int = 0 // 시간당 늘어나는 세균 수 // int를 double로, double에서 int로 형변환 필요 answer = 2.toDouble().pow(t).toInt() // 초기 세균수에 곱하기 answer *= n return .. 2023. 3. 20. 이전 1 2 3 4 ··· 9 다음