Python1423 백준 26575 Pups https://www.acmicpc.net/problem/26575 26575번: Pups Congratulations, you adopted some little puppies! Now you just need to go grab food for them at the store. Your vet tells you how many pounds of food each pup will eat before your next trip to the store, so you just need to calculate the total amount of fo www.acmicpc.net 1 2 3 4 5 6 if __name__ == '__main__': n = int(input()) for _ in range(n):.. 2023. 2. 27. 백준 26471 Farma https://www.acmicpc.net/problem/26741 26741번: Farma Bajtek ma farmę a na niej pewną liczbę kur i krów. Razem wszystkie te zwierzęta mają dokładnie X głów oraz Y nóg. Wszystkie kury mają po dwie nogi, a wszystkie krowy mają po cztery nogi. Oczywiście zarówno kury, jak i krowy mają po jednej g www.acmicpc.net 1 2 3 4 5 6 7 8 9 def sol(x, y): return int((4 * x - y) / 2), -int((2 * x - y) / 2) if __.. 2023. 2. 24. 백준 9771 Word Searching https://www.acmicpc.net/problem/9771 9771번: Word Searching The first line contains a single word to search. A word contains at most 20 characters. The next line and the rest is a text to search for that word. The text can contain up to 100 lines including blank lines. No line exceeds 250 characters. A word cannot www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 if __name__ == '__main__': target = i.. 2023. 2. 24. 백준 27541 末尾の文字 (Last Letter) https://www.acmicpc.net/problem/27541 27541번: 末尾の文字 (Last Letter) 葵が見た文字列 JOI の末尾の文字は G でないので,葵は末尾に文字 G を付け加えた文字列 JOIG を思い浮かべる.そのため,JOIG を出力する. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 def sol(n, s) -> str: if s[-1] == 'G': return s[:n - 1] else: return s + 'G' if __name__ == '__main__': n = int(input()) s = str(input()) print(sol(n, s)) cs 슬라이싱을 활용해서 주어진 문자열의 마지막 글자가 'G'로 끝나는지 확인하면 됩니다. Using.. 2023. 2. 24. leetcode 232. Implement Queue using Stacks https://leetcode.com/problems/implement-queue-using-stacks/description/ Implement Queue using Stacks - LeetCode Implement Queue using Stacks - Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, peek, pop, and empty). Implement the MyQueue class: * void push(int x) Pushes leetcode.com 1 2 3 4 5 6 7 8 9.. 2023. 2. 23. leetcode 225. Implement Stack using Queues https://leetcode.com/problems/implement-stack-using-queues/ Implement Stack using Queues - LeetCode Can you solve this real interview question? Implement Stack using Queues - Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top, pop, and empty). Implement the leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 1.. 2023. 2. 23. leetcode 739. Daily Temperatures https://leetcode.com/problems/daily-temperatures/description/ Daily Temperatures - LeetCode Can you solve this real interview question? Daily Temperatures - Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer leetcode.com 1 2 3 4 5 6 7 8 9 10 11 class Solutio.. 2023. 2. 23. leetcode 316. Remove Duplicate Letters https://leetcode.com/problems/remove-duplicate-letters/description/ Remove Duplicate Letters - LeetCode Can you solve this real interview question? Remove Duplicate Letters - Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible re leetcode.com 1 2 3 4 5 6 7 8 9 10 11 .. 2023. 2. 23. leetcode 20. Valid Parentheses https://leetcode.com/problems/valid-parentheses/description/ Valid Parentheses - LeetCode Can you solve this real interview question? Valid Parentheses - Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the sam leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 cl.. 2023. 2. 23. 백준 9773 ID Key https://www.acmicpc.net/problem/9773 9773번: ID Key บรรทัดแรกคือค่า N (1 ≤ N ≤ 100) ระบุจํานวนคน และ N บรรทัดต่อมา แต่ละบรรทัดคือเลขประจําตัวประชาชน 13 ห www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 def sol(s) -> int: first, last_three_number = 0, 0 for i in s: first += int(i) last_three_number = int(s[-3] + s[-2] + s[-1]) * 10 answer = first + last_three_number if first + answer 2023. 2. 21. leetcode 92. Reverse Linked List II https://leetcode.com/problems/reverse-linked-list-ii/description/ Reverse Linked List II - LeetCode Can you solve this real interview question? Reverse Linked List II - Given the head of a singly linked list and two integers left and right where left ListNode: if not head or not head.next or left == right: return head # left-1 노드를 찾습니다. dummy = ListNode(-1) dummy.next = head prev = dummy for i i.. 2023. 2. 17. leetcode 328. Odd Even Linked List https://leetcode.com/problems/odd-even-linked-list/description/ Odd Even Linked List - LeetCode Odd Even Linked List - Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered odd, and the second node is even, and so on. N leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14.. 2023. 2. 17. 이전 1 ··· 13 14 15 16 17 18 19 ··· 119 다음