전체 글1534 3300. Minimum Element After Replacement With Digit Sum https://leetcode.com/problems/minimum-element-after-replacement-with-digit-sum/123456class Solution: def minElement(self, nums: List[int]) -> int: answer = [sum(map(int, str(nums[i]))) for i in range(len(nums))] return min(answer)Colored by Color Scriptercslist comprehension과 각 자리수 합을 구하기 위해서원본 데이터 타입을 문자열로 타입 캐스팅해서 사용합니다. 2024. 10. 5. leetcode 3210. Find the Encrypted String https://leetcode.com/problems/find-the-encrypted-string/description/12345678class Solution: def getEncryptedString(self, s: str, k: int) -> str: answer = "" for i in range(len(s)): answer += s[(i+k)%len(s)] return answerColored by Color Scriptercs문자열 s 를 rotate 하는 느낌으로 구현 2024. 9. 23. 3194. Minimum Average of Smallest and Largest Elements https://leetcode.com/problems/minimum-average-of-smallest-and-largest-elements/description/12345678910class Solution: def minimumAverage(self, nums: List[int]) -> float: nums.sort() averages = [] for i in range(len(nums)//2): averages.append((nums[i] + nums[-(i+1)])/2) return min(averages) Colored by Color Scriptercs 2024. 9. 21. 3232. Find if Digit Game Can Be Won https://leetcode.com/problems/find-if-digit-game-can-be-won/description/ 1234567891011121314class Solution: def canAliceWin(self, nums: List[int]) -> bool: sum_single, sum_double = 0, 0 for num in nums: if num 10 : sum_single += num else: sum_double += num if sum_single == sum_double: return False els.. 2024. 9. 21. 3285. Find Indices of Stable Mountains https://leetcode.com/problems/find-indices-of-stable-mountains/description/ 12345678class Solution: def stableMountains(self, height: List[int], threshold: int) -> List[int]: answer = [] for i in range(1, len(height)): if height[i - 1] > threshold: answer.append(i) return answerColored by Color Scriptercsheight 리스트를 순차 탐색하면서 바로 직전 값이 thre.. 2024. 9. 21. 3190. Find Minimum Operations to Make All Elements Divisible by Three https://leetcode.com/problems/find-minimum-operations-to-make-all-elements-divisible-by-three/description/ 123456789class Solution: def minimumOperations(self, nums: List[int]) -> int: answer = 0 for num in nums: if num % 3 != 0: answer += 1 return answer Colored by Color Scriptercscase 1 ) 숫자가 3으로 나눴을때 나머지 가 0 인 경우 : 아무것도 안해도됨cas.. 2024. 9. 19. leetcode 3280. Convert Date to Binary https://leetcode.com/problems/convert-date-to-binary/description/12345class Solution: def convertDateToBinary(self, date: str) -> str: yyyy, mm, dd = map(int, date.split("-")) return bin(yyyy)[2:]+"-"+bin(mm)[2:]+"-"+bin(dd)[2:]cspython 내장함수 bin을 통해 구현 2024. 9. 12. leetcode 1684. Count the Number of Consistent Strings https://leetcode.com/problems/count-the-number-of-consistent-strings/description/?envType=daily-question&envId=2024-09-12 12345678910class Solution: def countConsistentStrings(self, allowed: str, words: List[str]) -> int: answer = 0 allowed_set = set(list(allowed)) for word in words: word_set = set(list(word)) if word_set.issubset(allowed_set) : .. 2024. 9. 12. leetcode 3270. Find the Key of the Numbers https://leetcode.com/problems/find-the-key-of-the-numbers/description/ 1234567891011121314class Solution: def generateKey(self, num1: int, num2: int, num3: int) -> int: str_num1, str_num2, str_num3 = str(num1), str(num2), str(num3) max_length = max(len(str_num1), len(str_num2), len(str_num3)) str_num1 = str_num1.zfill(max_length) str_num2 = str_num2.zfill(max_leng.. 2024. 9. 2. 백준 31994 강당 대관 https://www.acmicpc.net/problem/31994 123456789def sol(seminar_list): seminar_list.sort(key=lambda x: -int(x[1])) return seminar_list[0][0] if __name__ == '__main__': seminar_list = [input().split() for i in range(7)] print(sol(seminar_list)) Colored by Color Scriptercs 2024. 7. 15. 백준 32025 체육은 수학과목 입니다 https://www.acmicpc.net/problem/32025 12345678910def sol(h, w): return min(h, w) * 100 // 2 if __name__ == '__main__': h = int(input()) w = int(input()) print(sol(h, w)) Colored by Color Scriptercs 2024. 7. 15. 백준 30979 유치원생 파댕이 돌보기 https://www.acmicpc.net/problem/30979 12345678910111213def sol(t, candys): if t > candys: return "Padaeng_i Cry" else: return "Padaeng_i Happy" if __name__ == '__main__': t = int(input()) n = int(input()) candys = sum(list(map(int, input().split()))) print(sol(t, candys)) Colored by Color Scriptercs 2024. 6. 19. 이전 1 2 3 4 ··· 128 다음