[LeetCode][Kotlin] 219. Contains Duplicate II
219. Contains Duplicate IIGiven an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) 정수 배열 nums와 정수 k가 주어졌을 때, 배열에 두 개의 서로 다른 인덱스 i와 j가 있고 nums[i] == nums[j]이고 abs(i - j) Example 1:Input: nums = [1,2,3,1], k = 3Output: true Example 2:Input: nums = [1,0,1,1], k = 1Output: true Example 3:Input: nums ..
2024. 10. 23.
[LeetCode][Kotlin] 42. Trapping Rain Water
42. Trapping Rain WaterGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.너비가 1인 고도 지도를 나타내는 음이 아닌 정수 n개가 주어졌을 때, 비가 내린 후에 얼마나 많은 물을 가둘 수 있는지 계산하세요. Example 1:Input: height = [0,1,0,2,1,0,1,3,2,1,2,1]Output: 6Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1..
2024. 10. 21.