본문 바로가기

코틀린18

85 프로그래머스] 최댓값 만들기(1) kotlin class Solution { fun solution(numbers: IntArray): Int { var answer: Int = 0 numbers.sort() answer = numbers[numbers.size -1] * numbers[numbers.size -2] return answer } } https://skytitan.tistory.com/184 [코틀린] 배열 정렬하기 원본 배열 정렬 1. sort() 원본 배열을 오름차순으로 정렬한다. import java.util.* fun main() { var arr = arrayOf(0, 7, 4, 3, 2, 6, 5, 1 ) arr.sort() println(Arrays.toString(arr)) /* 결과 [0, 1, 2, 3, 4, 5, 6.. 2023. 10. 14.
77] Leetcode 1979. Find Greatest Common Divisor of Array #Kotlin https://leetcode.com/problems/find-greatest-common-divisor-of-array/description/ Find Greatest Common Divisor of Array - LeetCode Can you solve this real interview question? Find Greatest Common Divisor of Array - Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums. The greatest common divisor of two numbers is the largest leetcode.co.. 2023. 4. 12.
66] Kotlin 프로그래머스 / x만큼 간격이 있는 n개의 숫자 class Solution { fun solution(x: Int, n: Int): LongArray { // n 크기의 배열 선언 val answer = LongArray(n) for (i in 0 until n) { // 둘다 가능 answer[i] = (i + 1) * x.toLong() // answer.set(i, ((i+1) * x.toLong()) } return answer } } 코틀린으로 알고리즘 풀려니 헷갈려,, class Solution { fun solution(x: Int, n: Int): LongArray { // n 크기의 배열 선언 val answer = LongArray(n){i-> x.toLong() * (i + 1).toLong() } return answer } } .. 2021. 9. 28.
Kotlin] 안드로이드 국가별 시간, 날짜 표시 // getBestDateTimePattern Format DateTime in Android - AndroidWave In this tutorials, We explain How to Format DateTime in Android using SimpleDateFormat. Example Include - Format Date to Text and Parse Text to Date androidwave.com Codota Codota search - find any Java class or method www.codota.com val skeleton: String = DateFormat.getBestDateTimePattern(Locale.getDefault(), "MMMM d") val formatter = SimpleDateFormat(ske.. 2021. 5. 20.