개발공부/LeetCode

    [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..