본문 바로가기

Python1423

leetcode 2928. Distribute Candies Among Children I https://leetcode.com/problems/distribute-candies-among-children-i/ Distribute Candies Among Children I - LeetCode Can you solve this real interview question? Distribute Candies Among Children I - You are given two positive integers n and limit. Return the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies. leetcode.com 1 2 3 4 5 6 7 8 9 .. 2023. 12. 27.
leetcode CodeTestcaseTestcaseTest Result2942. Find Words Containing Character https://leetcode.com/problems/find-words-containing-character/description/ Find Words Containing Character - LeetCode Can you solve this real interview question? Find Words Containing Character - You are given a 0-indexed array of strings words and a character x. Return an array of indices representing the words that contain the character x. Note that the returned array m leetcode.com 123456789c.. 2023. 12. 27.
leetcode 2951. Find the Peaks https://leetcode.com/problems/find-the-peaks/description/ Find the Peaks - LeetCode Can you solve this real interview question? Find the Peaks - You are given a 0-indexed array mountain. Your task is to find all the peaks in the mountain array. Return an array that consists of indices of peaks in the given array in any order. Notes: * A p leetcode.com 123456789class Solution: def findPeaks(self,.. 2023. 12. 27.
leetcode 2956. Find Common Elements Between Two Arrays https://leetcode.com/problems/find-common-elements-between-two-arrays/description/ Find Common Elements Between Two Arrays - LeetCode Can you solve this real interview question? Find Common Elements Between Two Arrays - You are given two 0-indexed integer arrays nums1 and nums2 of sizes n and m, respectively. Consider calculating the following values: * The number of indices i such that leetcode.. 2023. 12. 27.
leetcode 2965. Find Missing and Repeated Values https://leetcode.com/problems/find-missing-and-repeated-values/description/ Find Missing and Repeated Values - LeetCode Can you solve this real interview question? Find Missing and Repeated Values - You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2]. Each integer appears exactly once except a which appears twice and b which is mi leetcode.com 12345678.. 2023. 12. 27.
백준 4388 받아올림 https://www.acmicpc.net/problem/4388 4388번: 받아올림 어린이에게 여러자리 숫자의 덧셈을 가르칠 때는 오른쪽 자리부터 왼쪽으로 하나씩 계산하는 방법을 가르쳐준다. 이때, 받아올림이 발생하게 되며 아이들은 여기서 혼란에 빠진다. 받아올림이 www.acmicpc.net 12345678910111213141516171819202122def sol(n1, n2): n1 = n1.zfill(max(len(n1), len(n2)))[::-1] n2 = n2.zfill(max(len(n1), len(n2)))[::-1] answer = 0 carry = 0 for i in range(len(n1)): if int(n1[i]) + int(n2[i]) + carry >= 10: answe.. 2023. 12. 27.
백준 6550 부분 문자열 https://www.acmicpc.net/problem/6550 6550번: 부분 문자열 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있으며, 문자열 s 와 t가 빈칸을 사이에 두고 들어온다. s와 t의 길이는 10만을 넘지 않는다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 def sol(s, t): check = 0 for i in t: if s[check] == i: check += 1 if check == len(s): return 'Yes' return 'No' if __name__ == '__main__': while True: try: s, t = input().split.. 2023. 12. 23.
백준 11723 집합 https://www.acmicpc.net/problem/11723 11723번: 집합 첫째 줄에 수행해야 하는 연산의 수 M (1 ≤ M ≤ 3,000,000)이 주어진다. 둘째 줄부터 M개의 줄에 수행해야 하는 연산이 한 줄에 하나씩 주어진다. 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 25 26 27 28 import sys if __name__ == '__main__': m = int(sys.stdin.readline()) s = set() for i in range(m): operation = list(sys.stdin.readline().strip().split()) if len(operation.. 2023. 12. 23.
백준 30045 ZOAC 6 https://www.acmicpc.net/problem/30045 30045번: ZOAC 6 2023년 9월, 여섯 번째로 개최된 ZOAC의 오프닝을 또 맡은 성우는 영과일의 마스코트인 영일이를 이용해 대회를 홍보하기로 했다. 성우는 홍보 글이 주어질 때 각 문장에 01 또는 OI가 포함되어 있다 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 def sol(strings): answer = 0 for i in strings: if '01' in i or 'OI' in i: answer += 1 return answer if __name__ == '__main__': n = int(input()) strings = [input() for i in range(n)].. 2023. 12. 20.
백준 30468 호반우가 학교에 지각한 이유 1 https://www.acmicpc.net/problem/30468 30468번: 호반우가 학교에 지각한 이유 1 첫 번째 줄에 $STR,\,DEX,\,INT,\,LUK$과 $N$이 공백을 두고 주어진다. $(1 \le STR,\,DEX,\,INT,\,LUK,\,N \le 100)$ 입력되는 모든 수는 양의 정수이다. www.acmicpc.net 123456789101112def sol(s, d, i, l, n): stats = n * 4 - sum((s, d, i, l)) if stats >= 0: return stats else: return 0 if __name__ == '__main__': s, d, i, l, n = map(int, input().split()) print(sol(s, d, i,.. 2023. 12. 20.
백준 1120 문자열 https://www.acmicpc.net/problem/1120 1120번: 문자열 길이가 N으로 같은 문자열 X와 Y가 있을 때, 두 문자열 X와 Y의 차이는 X[i] ≠ Y[i]인 i의 개수이다. 예를 들어, X=”jimin”, Y=”minji”이면, 둘의 차이는 4이다. 두 문자열 A와 B가 주어진다. 이때, A의 www.acmicpc.net 1234567891011121314def sol(a, b): scores = [] for i in range(len(b) - len(a) + 1): score = 0 for j in range(len(a)): if a[j] != b[i + j]: score += 1 scores.append(score) return min(scores) a, b = input.. 2023. 12. 6.
백준 25178 두라무리 휴지 https://www.acmicpc.net/problem/25178 25178번: 두라무리 휴지 기령이는 어느 날 캠릿브지 대학의 연결구과에 대해 알게 되었다. 캠릿브지 대학의 연결구과란, 단어를 이해함에 있어 한 단어 안에서 글자들이 어떤 순서로 배열되어 있는지는 중요하지 않고, www.acmicpc.net 123456789101112131415161718192021222324252627282930313233343536373839def sol(s1, s2): def first(s1, s2): if sorted(s1) == sorted(s2): return True else: return False def second(s1, s2): if s1[0] == s2[0] and s1[-1] == s2[-1]:.. 2023. 12. 6.