본문 바로가기

leetcode73

[LeetCode][Kotlin] 1544. Make The String Great 1544. Make The String GreatGiven a string s of lower and upper case English letters. A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where:0 s[i] is a lower-case letter and s[i + 1] is the same letter but in upper-case or vice-versa.To make the string good, you can choose two adjacent characters that make the string bad and remove them. You can keep doing t.. 2024. 11. 27.
[LeetCode][Kotlin] 2009. Minimum Number of Operations to Make Array Continuous 2009. Minimum Number of Operations to Make Array ContinuousYou are given an integer array nums. In one operation, you can replace any element in nums with any integer.nums is considered continuous if both of the following conditions are fulfilled:All elements in nums are unique.The difference between the maximum element and the minimum element in nums equals nums.length - 1.For example, nums = [.. 2024. 11. 26.
[LeetCode][Kotlin] 992. Subarrays with K Different Integers 992. Subarrays with K Different IntegersGiven an integer array nums and an integer k, return the number of good subarrays of nums.A good array is an array where the number of different integers in that array is exactly k.For example, [1,2,3,1,2] has 3 different integers: 1, 2, and 3.A subarray is a contiguous part of an array.정수 배열 nums와 정수 k가 주어지면 nums의 좋은 부분 배열의 개수를 반환합니다. 좋은 배열은 해당 배열의 다른 정수의.. 2024. 11. 22.
[LeetCode][Kotlin] 239. Sliding Window Maximum 239. Sliding Window MaximumYou are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window.정수 nums 배열이 주어지고, 배열의 가장 왼쪽에서 가장 오른쪽으로 이동하는 k 크기의 슬라이딩 윈도우가 있습니다. 윈도우에서 k개의 숫자만 볼 수 있습니다. 슬라이.. 2024. 11. 21.
[LeetCode][Kotlin] 76. Minimum Window Substring 76. Minimum Window SubstringGiven two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. If there is no such substring, return the empty string "". The testcases will be generated such that the answer is unique.각각 길이가 m과 n인 두 개의 문자열 s와 t가 주어지면 t의 모든 문자(중복 포함)가 윈도우에 포함되도록 s의 최소 .. 2024. 11. 18.
[LeetCode][Kotlin] 2962. Count Subarrays Where Max Element Appears at Least K Times 2962. Count Subarrays Where Max Element Appears at Least K TimesYou are given an integer array nums and a positive integer k. Return the number of subarrays where the maximum element of nums appears at least k times in that subarray. A subarray is a contiguous sequence of elements within an array.정수 배열 nums와 양의 정수 k가 주어집니다. nums의 최대 요소가 해당 하위 배열에 최소 k번 나타나는 하위 배열의 개수를 반환합니다. 하위 배열은 배열 내의 연속된 요소 .. 2024. 11. 16.
[LeetCode][Kotlin] 930. Binary Subarrays With Sum 930. Binary Subarrays With SumGiven a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal. A subarray is a contiguous part of the array.이진 배열 nums와 정수 goal이 주어지면, sum goal을 사용하여 비어 있지 않은 부분 배열의 개수를 반환합니다. 부분 배열은 배열의 연속된 부분입니다. Example 1:Input: nums = [1,0,1,0,1], goal = 2Output: 4Explanation: The 4 subarrays are bolded and underlined below:[1,0,1,0,1][.. 2024. 11. 15.