전체 글

전체 글

    [Kotlin] 코루틴 Coroutine 사용법 - runBlocking 사용법 및 예제 - 2편

    [Kotlin] 코루틴 Coroutine 사용법 및 개념 정리 - runBlocking - 2편 이전 포스트:[Kotlin] 코루틴 Coroutine 사용법 및 개념 정리 - GlobalScope, Delay, Dispatcher, Coroutine Context - 1편 [Kotlin] 코루틴 Coroutine 사용법 및 개념 정리 - GlobalScope, Delay, Dispatcher, Coroutine Context - 1편 [Kotlin] 코루틴 Coroutine 사용법 및 개념 정리 - GlobalScope, Delay, Dispatcher, Coroutine Context - 1편 Coroutine 개념 Coroutine은 다양한 테스크를 진행할 때 필요한 요소입니다. 스레드(T.. und..

    [Kotlin] LeetCode: Intersection of Two Arrays IISolution 풀이

    [Kotlin] LeetCode: Intersection of Two Arrays IISolution 풀이

    문제 Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in both arrays and you may return the result in any order. nums1과 nums2 에서 겹치는 원소를 모아서 intArray로 반환해야 합니다. 예시 풀이 class Solution { fun intersect(nums1: IntArray, nums2: IntArray): IntArray? { //기본값들을 initialize 해줍니다 val list: MutableList = ArrayList(..

    [Kotlin] 코루틴 Coroutine 사용법 및 개념 정리 - GlobalScope, GlobalScope.launch, Delay, Dispatcher, Coroutine Context - 1편

    [Kotlin] 코루틴 Coroutine 사용법 및 개념 정리 - GlobalScope, GlobalScope.launch, Delay, Dispatcher, Coroutine Context - 1편

    [Kotlin] 코루틴 Coroutine 사용법 및 개념 정리 - GlobalScope, GlobalScope.launch, Delay, Dispatcher, Coroutine Context - 1편 이번포스트에서는 GlobalScope, GlobalScope.launch, Delay, Dispatcher, Coroutine Context 의 개념과 사용 예시를 다뤄보도록 하겠습니다. Coroutine 개념 Coroutine은 다양한 테스크를 진행할 때 필요한 요소입니다. 스레드(Thread)와 햇갈리실수 있는데 스레드와 다른 점은 1. Coroutine은 스레드와 함께 사용되고 2. Coroutine은 코드를 실행 중일 때 멈출 수 있고(suspendable) 다시 실행할 수 있는(resume) 제어 ..

    [Kotlin] Array 에 같은 숫자 찾기, HashMap활용 풀이 - LeetCode: Single Number

    [Kotlin] Array 에 같은 숫자 찾기, HashMap활용 풀이 - LeetCode: Single Number

    문제 Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. int로만 이루어진 nums array에서 2번 이상 반복되지 않는 수를 찾아야 합니다. 예시 intArray를 input으로 받고 반복되지않은 수를 output으로 내보내야 합니다. 풀이 class Solution { fun singleNumber(nums: IntArray): Int { //Int를 반환합니다. val hash_tab..

    [Kotlin] Collection 정리 list, set, map 차이 - HashMap, hashmapof, mutableMap, setOf, mutableSetOf,ArrayListof,listof 사용법 및 차이

    [Kotlin] Collection 정리 list, set, map 차이 - HashMap, hashmapof, mutableMap, setOf, mutableSetOf,ArrayListof,listof 사용법 및 차이

    [Kotlin] Collection 정리 list, set, map 차이 - HashMap, HashMapOf, MutableMap, SetOf, MutableSetOf, ArrayListof, ListOf HashMap, hashmapof, mutableMap, setOf, mutableSetOf, ArrayListof, listof 들의 공통점은 모두 Collection이라는 점입니다. collection은 데이터를 모아 관리와 사용을 편리하게 하기 위해 만들어진 프레임워크입니다. Collection들을 이해하기 전 Collection을 구분 짓는 법부터 알아야 합니다. 코틀린은 크게 변경 가능한(Mutable), 변경 불가능한(Immutable) Collection으로 나눕니다. 그리고 그아래 Li..

    [Kotlin] Array에 반복되는 아이템 삭제하기 - ArrayList distinct - LeetCode: Contains Duplicate - 풀이 과정

    [Kotlin] Array에 반복되는 아이템 삭제하기 - ArrayList distinct - LeetCode: Contains Duplicate - 풀이 과정

    [Kotlin] Array에 반복되는 아이템 삭제하기 - ArrayList distinct - LeetCode: Contains Duplicate - 풀이 과정 문제 Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. Array에서 2번이상 반복되는 value가 있을경우 true를 return하고 반복되는 값이없으면 false를 return 하도록 하는게 이 문제의 목표입니다. Arraylist에 Distinct를 사용해서 반복되는 값을 지우고 기존 Array와 지운값의 Array를 비교하여 boolean을 반환..

    [Kotlin] LeetCode - Best Time to Buy and Sell Stock IISolution - 풀이과정

    [Kotlin] LeetCode - Best Time to Buy and Sell Stock IISolution - 풀이과정

    문제 You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times). Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again). 그날의 stock 가격이 prices라는 array에..

    [Kotlin] String, Int 순서 뒤집기 - LeetCode: Reverse Integer 풀이

    [Kotlin] String, Int 순서 뒤집기 - LeetCode: Reverse Integer 풀이

    문제 Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned). 예시 x를 넣으면 reversed된 값을 반환하게 만들어야합니다. 풀이 1. String으로 변환후 순서 뒤집기 저는 integer을 string으로 바꿔서 char 하나씩 접근하여 보내려했는데 //오답 fun reverse(x:..

    [Kotlin] LeetCode 1. Two Sum 풀이 - for index, indices 활용

    [Kotlin] LeetCode 1. Two Sum 풀이 - for index, indices 활용

    문제 Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. 예시 위와같이 nums와 target이 fun twoSum에 들어가서 반환값이 0,1이 나와야하게 만들어야합니다. 0,1은 nums의 index(위치) 값이고 둘의 합은 9가 되어야합니다. 둘의 합이 9가되는 두 숫자의 in..