Kotlin147 [LeetCode][Kotlin] 451. Sort Characters By Frequency 451. Sort Characters By FrequencyGiven a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string. Return the sorted string. If there are multiple answers, return any of them.문자열 s가 주어지면 문자 빈도에 따라 내림차순으로 정렬합니다. 문자의 빈도는 해당 문자가 문자열에 나타나는 횟수입니다. 정렬된 문자열을 반환합니다. 답변이 여러 개인 경우 답변 중 하나를 반환하세요. Example 1:.. 2024. 10. 19. [LeetCode][Kotlin] 1685. Sum of Absolute Differences in a Sorted Array 1685. Sum of Absolute Differences in a Sorted ArrayYou are given an integer array nums sorted in non-decreasing order. Build and return an integer array result with the same length as nums such that result[i] is equal to the summation of absolute differences between nums[i] and all the other elements in the array. In other words, result[i] is equal to sum(|nums[i]-nums[j]|) where 0 0-indexed).비내.. 2024. 10. 18. [LeetCode][Kotlin] 2483. Minimum Penalty for a Shop 2483. Minimum Penalty for a ShopYou are given the customer visit log of a shop represented by a 0-indexed string customers consisting only of characters 'N' and 'Y':if the ith character is 'Y', it means that customers come at the ith hourwhereas 'N' indicates that no customers come at the ith hour.If the shop closes at the jth hour (0 penalty is calculated as follows:For every hour when the shop.. 2024. 10. 18. [LeetCode][Kotlin] 41. First Missing Positive 41. First Missing PositiveGiven an unsorted integer array nums. Return the smallest positive integer that is not present in nums. You must implement an algorithm that runs in O(n) time and uses O(1) auxiliary space.정렬되지 않은 정수 배열 nums가 주어졌습니다. nums에 존재하지 않는 가장 작은 양의 정수를 반환합니다. O(n) 시간에 실행되고 O(1) 보조 공간을 사용하는 알고리즘을 구현해야 합니다. Example 1:Input: nums = [1,2,0]Output: 3Explanation: The numbers in the ra.. 2024. 10. 18. [LeetCode][Kotlin] 665. Non-decreasing Array 665. Non-decreasing ArrayGiven an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element. We define an array is non-decreasing if nums[i] 0-based) such that (0 n개의 정수로 구성된 nums 배열이 주어지면, 최대 하나의 요소를 수정하여 감소하지 않는 배열이 될 수 있는지 확인하는 것이 작업입니다. nums[i] Example 1:Input: nums = [4,2,3]Output: trueExplanation: You could modify the first 4 to 1.. 2024. 10. 18. [LeetCode][Kotlin] 304. Range Sum Query 2D - Immutable 304. Range Sum Query 2D - ImmutableGiven a 2D matrix matrix, handle multiple queries of the following type:Calculate the sum of the elements of matrix inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).Implement the NumMatrix class:NumMatrix(int[][] matrix) Initializes the object with the integer matrix matrix.int sumRegion(int row1, int col1, .. 2024. 10. 18. [LeetCode][Kotlin] 838. Push Dominoes 838. Push DominoesThere are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right. After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the right push their adjacent dominoes standing on the right. When a ve.. 2024. 10. 18. 이전 1 2 3 4 5 6 7 8 ··· 21 다음