본문 바로가기

전체 글1534

leetcode 49. Group Anagrams https://leetcode.com/problems/group-anagrams/description/ Group Anagrams - LeetCode Can you solve this real interview question? Group Anagrams - Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase leetcode.com 1 2 3 4 5 6 7 8 9 10 import collections clas.. 2023. 2. 7.
leetcode 819. Most Common Word https://leetcode.com/problems/most-common-word/description/ Most Common Word - LeetCode Most Common Word - Given a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned. It is guaranteed there is at least one word that is not banned, and that the answer is unique. The words in paragra leetcode.com 1 2 3 4 5 6 7 8 9 10 11 import re import.. 2023. 2. 7.
leetcode 937. Reorder Data in Log Files https://leetcode.com/problems/reorder-data-in-log-files/description/ Reorder Data in Log Files - LeetCode Reorder Data in Log Files - You are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier. There are two types of logs: * Letter-logs: All words (except the identifier) consist of lowercase English le leetcode.com 1 2 3 4 5 6 7 8 9 10 1.. 2023. 2. 7.
leetcode 1967. Number of Strings That Appear as Substrings in Word https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/description/ Number of Strings That Appear as Substrings in Word - LeetCode Number of Strings That Appear as Substrings in Word - Given an array of strings patterns and a string word, return the number of strings in patterns that exist as a substring in word. A substring is a contiguous sequence of characters withi.. 2023. 2. 3.
백준 27332 11 月 (November) https://www.acmicpc.net/problem/27332 27332번: 11 月 (November) 2022 年 11 月 3 日の 4 週間後の日は 2022 年 12 月 1 日である.この日は 2022 年 11 月ではないので 0 を出力する. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import datetime def sol(a, b): current_date = datetime.date(2022, 11, a) weeks = datetime.timedelta(weeks=b) that_day = current_date + weeks if that_day.year == 2022 and that_day.month == 11: ret.. 2023. 2. 1.
백준 27294 몇개고? https://www.acmicpc.net/problem/27294 27294번: 몇개고? 첫 번째 줄에 시간을 의미하는 정수 $T$ ($0 \le T \le 23$)와 술의 유무를 의미하는 정수 $S$ ($0 \le S \le 1$)가 공백으로 구분되어 주어진다. $T$가 $11$이하이면 아침 시간, $12$이상 $16$ 이하이면 점심 시 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 def sol(t, s): if t>=12 and t 2023. 1. 31.
백준 27328 三方比較 (Three-Way Comparison) https://www.acmicpc.net/problem/27328 27328번: 三方比較 (Three-Way Comparison) 2 つの整数 A, B が与えられる. A と B の大小を比較し,A < B ならば -1 を,A = B ならば 0 を,A > B ならば 1 を出力せよ. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 def sol(a, b): if a>b: return 1 elif a == b: return 0 else: return -1 if __name__ == '__main__': a = int(input()) b = int(input()) print(sol(a, b)) cs 2023. 1. 31.
백준 27327 時間 (Hour) https://www.acmicpc.net/problem/27327 27327번: 時間 (Hour) X 日は何時間か,単位 (時間) を省いて出力せよ. www.acmicpc.net 1 2 3 4 5 6 7 8 9 def sol(n): answer = n*24 return answer if __name__ == '__main__': n = int(input()) print(sol(n)) cs 2023. 1. 31.
백준 27331 2 桁の整数 (Two-digit Integer) https://www.acmicpc.net/problem/27331 27331번: 2 桁の整数 (Two-digit Integer) 2 つの数字 A, B が与えられる. 十の位が A であり,一の位が B である 2 桁の正の整数を出力せよ. www.acmicpc.net 1 2 3 4 5 6 7 8 9 def sol(a, b): return a+b if __name__ == '__main__': a = str(input()) b = str(input()) print(sol(a, b)) cs 2023. 1. 31.
백준 27324 ゾロ目 (Same Numbers) https://www.acmicpc.net/problem/27324 27324번: ゾロ目 (Same Numbers) N の十の位の数字と一の位の数字が同じである場合は 1 を,そうでない場合は 0 を出力せよ. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 def sol(n): if n%10 == n//10 : return 1 else: return 0 if __name__ == '__main__': n = int(input()) print(sol(n)) cs 2023. 1. 31.
백준 27323 長方形 (Rectangle) https://www.acmicpc.net/problem/27323 27323번: 長方形 (Rectangle) 整数 A, B が与えられる.縦の辺の長さが A cm,横の辺の長さが B cm である下図のような長方形の面積は何 cm2 か求めよ. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 def sol(a, b): answer = a * b return answer if __name__ == '__main__': a = int(input()) b = int(input()) print(sol(a, b)) cs 2023. 1. 31.
leetcode 1137. N-th Tribonacci Number https://leetcode.com/problems/n-th-tribonacci-number/description/ N-th Tribonacci Number - LeetCode N-th Tribonacci Number - The Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. Given n, return the value of Tn. Example 1: Input: n = 4 Output: 4 Explanation: T_3 = 0 + 1 + 1 = 2 T_4 = 1 + 1 leetcode.com 1 2 3 4 5 6 7 8 9 10 11 class Solu.. 2023. 1. 30.