분류 전체보기1543 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. leetcode 2000. Reverse Prefix of Word https://leetcode.com/problems/reverse-prefix-of-word/description 1234567class Solution: def reversePrefix(self, word: str, ch: str) -> str: if word.find(ch) == -1: return word else: return word[:word.find(ch)+1][::-1] + word[word.find(ch)+1:] Colored by Color Scriptercs 2024. 5. 2. leetcode 3131. Find the Integer Added to Array I https://leetcode.com/problems/find-the-integer-added-to-array-i/description/ 123456class Solution: def addedInteger(self, nums1: List[int], nums2: List[int]) -> int: nums1.sort() nums2.sort() return nums2[0] - nums1[0] Colored by Color Scriptercs 2024. 4. 30. leetcode 1266. Minimum Time Visiting All Points https://leetcode.com/problems/minimum-time-visiting-all-points/ 12345678910111213141516171819202122232425262728293031323334353637383940414243class Solution: def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int: def sol(point1, point2): cost = 0 def move1(): nonlocal cost while point1[0] != point2[0] and point1[1] != poin.. 2024. 4. 27. 이전 1 2 3 4 5 ··· 129 다음