Problem Solving/LeetCode
2023.11.16 Today's Challenge
fabichoi
2023. 11. 16. 23:45
https://leetcode.com/problems/maximum-element-after-decreasing-and-rearranging/
Maximum Element After Decreasing and Rearranging - LeetCode
Can you solve this real interview question? Maximum Element After Decreasing and Rearranging - You are given an array of positive integers arr. Perform some operations (possibly none) on arr so that it satisfies these conditions: * The value of the first e
leetcode.com
Sorting해서 푸는 간단한 문제.
너무 간단해서 문제 이해를 못함 ㅋㅋ
class Solution:
def maximumElementAfterDecrementingAndRearranging(self, arr: List[int]) -> int:
arr.sort()
ans = 1
for i in range(1, len(arr)):
if arr[i] >= ans + 1:
ans += 1
return ans
반응형