본문 바로가기

python-algorithm1422

leetcode 3033. Modify the Matrix https://leetcode.com/problems/modify-the-matrix/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 class Solution: def modifiedMatrix(self, matrix: List[List[int]]) .. 2024. 2. 13.
leetcode 2357. Make Array Zero by Subtracting Equal Amounts https://leetcode.com/problems/make-array-zero-by-subtracting-equal-amounts/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1234567class Solution: def minimumOperations(self, nums: List[int]) -> int: nums = list.. 2024. 2. 9.
leetcode 2586. Count the Number of Vowel Strings in Range https://leetcode.com/problems/count-the-number-of-vowel-strings-in-range/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 class Solution: def vowelStrings(self, words: List[st.. 2024. 2. 9.
백준 Not A + B https://www.acmicpc.net/problem/23530 23530번: Not A + B You are required to output an integer $c$ for each test in a separate line. If there are multiple solutions, you may output any of them. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 def sol(a, b): return 1 if __name__ == '__main__': t = int(input()) for i in range(t): a, b = map(int, input().split()) print(sol(a, b)) Colored by Color Scripter cs a와.. 2024. 2. 9.
백준 27465 소수가 아닌 수 https://www.acmicpc.net/problem/27465 27465번: 소수가 아닌 수 이 대회의 운영진 중 한 명인 KSA 학생은 $17$시와 $19$시를 구별할 수 없다. 이는 당연하게도 $17$과 $19$가 모두 소수이기 때문일 것이다. 시간을 제대로 구별해서 KSA의 명예를 지키기 위해 정수 $N$ www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 def sol(n): return 10**9 # if n % 2 == 0: # return n + 2 # else: # return n + 3 if __name__ == '__main__': n = int(input()) print(sol(n)) cs 소수인 수를 찾으려면 에라토스테네스의 체나,, 반복문을 사용해야 .. 2024. 2. 9.
백준 14215 세 막대 https://www.acmicpc.net/problem/14215 14215번: 세 막대 첫째 줄에 a, b, c (1 ≤ a, b, c ≤ 100)가 주어진다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 def sol(a, b, c): for x in range(a, 0, -1): for y in range(b, 0, -1): for z in range(c, 0, -1): if x + y + z - max(x, y, z) > max(x, y, z): return x + y + z if __name__ == '__main__': a, b, c = map(int, input().split()) print(sol(a, b, c)) Colored by Color Script.. 2024. 2. 8.
백준 1308 D-Day https://www.acmicpc.net/problem/1308 1308번: D-Day 첫째 줄에 오늘의 날짜가 주어지고, 두 번째 줄에 D-Day인 날의 날짜가 주어진다. 날짜는 연도, 월, 일순으로 주어지며, 공백으로 구분한다. 입력 범위는 1년 1월 1일부터 9999년 12월 31일 까지 이다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 from datetime import date def sol(date1, date2, new_date1): different_date = (date2 - date1).days over_thousand = (date2 - new_date1).days if over_thousand >=.. 2024. 2. 8.
leetcode 2937. Make Three Strings Equal https://leetcode.com/problems/make-three-strings-equal/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class Solution: def findMinimumOperations(self, s1: str, s2: str, s3: str).. 2024. 2. 8.
백준 25206 너의 평점은 https://www.acmicpc.net/problem/25206 25206번: 너의 평점은 인하대학교 컴퓨터공학과를 졸업하기 위해서는, 전공평점이 3.3 이상이거나 졸업고사를 통과해야 한다. 그런데 아뿔싸, 치훈이는 깜빡하고 졸업고사를 응시하지 않았다는 사실을 깨달았다! 치 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 def sol(scores): grades = {'A+': 4.5, 'A0': 4.0, 'B+': 3.5, 'B0': 3.0, 'C+': 2.5, 'C0': 2.0, 'D+': 1.5, 'D0': 1.0, 'F': 0.0} total_gpa = total_class = 0 for score .. 2024. 2. 6.
leetcode 3028. Ant on the Boundary https://leetcode.com/problems/ant-on-the-boundary/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1 2 3 4 5 6 7 8 class Solution: def returnToBoundaryCount(self, nums: List[int]) -> int: location = answer = 0 f.. 2024. 2. 6.
leetcode 3019. Number of Changing Keys https://leetcode.com/problems/number-of-changing-keys/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1 2 3 4 5 6 7 8 9 class Solution: def countKeyChanges(self, s: str) -> int: answer = 0 for i in range(1, len.. 2024. 2. 5.
백준 9063 대지 https://www.acmicpc.net/problem/9063 9063번: 대지 첫째 줄에는 점의 개수 N (1 ≤ N ≤ 100,000) 이 주어진다. 이어지는 N 줄에는 각 점의 좌표가 두 개의 정수로 한 줄에 하나씩 주어진다. 각각의 좌표는 -10,000 이상 10,000 이하의 정수이다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 def sol(xs, ys): if len(list(set(xs))) == 1 or len(list(set(ys))) == 1: return 0 else: return (max(xs) - min(xs)) * (max(ys) - min(ys)) if __name__ == '__main__': n = int(inpu.. 2024. 1. 24.