[LeetCode][Kotlin] 907. Sum of Subarray Minimums
907. Sum of Subarray MinimumsGiven an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr. Since the answer may be large, return the answer modulo 10^9 + 7.정수 arr의 배열이 주어졌을 때, b가 arr의 모든 (인접한) 부분 배열에 걸쳐 있는 min(b)의 합을 구하세요. 답이 클 수 있으므로 답을 10^9 + 7로 나눈 나머지로 반환합니다. Example 1:Input: arr = [3,1,2,4]Output: 17Explanation: Subarrays are [3], [1], [2], [..
2024. 12. 3.
[Kotlin][Collection] subList
지정된 fromIndex(포함)와 toIndex(제외) 사이의 이 목록 부분에 대한 뷰를 반환합니다. 반환된 목록은 이 목록에 의해 백업되므로 반환된 목록의 비구조적 변경 사항은 이 목록에 반영되고 그 반대의 경우도 마찬가지입니다. 기본 목록의 구조적 변경 사항은 뷰의 동작을 정의되지 않게 만듭니다.public actual fun subList(fromIndex: Int, toIndex: Int): Listval numbers = mutableListOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)val subList = numbers.subList(2, 6)println(numbers) // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]println(subList) // [3,..
2024. 12. 2.