전체 글 63

908. Smallest Range I

DescriptionYou are given an integer array nums and an integer k.In one operation, you can choose any index i where 0 Codefunc smallestRangeI(nums []int, k int) int { min, max := nums[0], nums[0] for _, num := range nums { if num max { max = num } } if min+k >= max-k { return 0 } return (max - k) - (min + k)} smallestRangeI 함수는 배열 nums의 모든 요소에 대해 최소한의 조정을 통해 배열의 최대값과 최소값의 차이를 k 이하로 만들 때, 조..

leetcode , 백준 2024.05.16

1672. Richest Customer Wealth

DescriptionYou are given an m x n integer grid accounts where accounts[i][j] is the amount of money the i​​​​​​​​​​​th​​​​ customer has in the j​​​​​​​​​​​th​​​​ bank. Return the wealth that the richest customer has.A customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that has the maximum wealth. Example 1:Input: accounts = [[1,2,3..

leetcode , 백준 2024.04.29