[LeetCode][Kotlin] 448. Find All Numbers Disappeared in an Array
448. Find All Numbers Disappeared in an ArrayGiven an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums.nums[i]가 [1, n] 범위에 있는 n개의 정수로 구성된 배열이 주어지면, nums에 나타나지 않는 [1, n] 범위의 모든 정수 배열을 반환합니다. Example 1:Input: nums = [4,3,2,7,8,2,3,1]Output: [5,6] Example 2:Input: nums = [1,1]Output: [2] Constraints:n =..
2024. 8. 16.
[Kotlin][Collection] slice
지정된 인덱스 범위의 인덱스에 있는 요소를 포함하는 목록을 반환합니다.public fun List.slice(indices: IntRange): List { if (indices.isEmpty()) return listOf() return this.subList(indices.start, indices.endInclusive + 1).toList()}val numbers = listOf("one", "two", "three", "four", "five", "six")println(numbers.slice(1..3)) // [two, three, four]println(numbers.slice(0..4 step 2)) // [one, three, five]printl..
2024. 8. 16.