본문 바로가기

python-algorithm1402

leetcode 392. Is Subsequence https://leetcode.com/problems/is-subsequence/description/?envType=study-plan-v2&envId=top-interview-150 Is Subsequence - LeetCode Can you solve this real interview question? Is Subsequence - Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from the original string by deleting some (can be n leetcode.co.. 2023. 6. 19.
leetcode 13. Roman to Integer https://leetcode.com/problems/roman-to-integer/description/?envType=study-plan-v2&envId=top-interview-150 Roman to Integer - LeetCode Can you solve this real interview question? Roman to Integer - Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just tw leetcode.c.. 2023. 6. 19.
leetcode 27. Remove Element https://leetcode.com/problems/remove-element/description/?envType=study-plan-v2&envId=top-interview-150 Remove Element - LeetCode Can you solve this real interview question? Remove Element - Given an integer array nums and an integer val, remove all occurrences of val in nums in-place [https://en.wikipedia.org/wiki/In-place_algorithm]. The order of the elements may be changed. Then r leetcode.co.. 2023. 6. 19.
leetcode 744. Find Smallest Letter Greater Than Target https://leetcode.com/problems/find-smallest-letter-greater-than-target/description/ Find Smallest Letter Greater Than Target - LeetCode Can you solve this real interview question? Find Smallest Letter Greater Than Target - You are given an array of characters letters that is sorted in non-decreasing order, and a character target. There are at least two different characters in letters. Retu leetc.. 2023. 6. 9.
백준 28074 모비스 https://www.acmicpc.net/problem/28074 28074번: 모비스 주어진 문자열에 포함된 알파벳 대문자들을 이용해 MOBIS를 만들 수 있으면 "YES", 그렇지 않으면 "NO"를 출력한다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 def solution(s): answer = False if 'M' in s and 'O' in s and 'B' in s and 'I' in s and 'S' in s: answer = True if answer: return 'YES' else: return 'NO' if __name__ == '__main__': s = input() print(solution(s)) Colored by Color S.. 2023. 6. 8.
백준 28097 모범생 포닉스 https://www.acmicpc.net/problem/28097 28097번: 모범생 포닉스 모두가 알다시피, 포닉스는 포스텍을 대표하는 모범생이다! 포닉스는 최고의 모범생답게 남들과는 다른 공부 계획표를 가지고 있다. 포닉스는 총 $N$개의 공부 계획을 가지고 있다. $i$번째 공부 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 def solution(n, t): total = sum(t) + (n - 1) * 8 day, hour = total // 24, total % 24 return day, hour if __name__ == '__main__': n = int(input()) t = map(int, input().split()) print(*solution(n, t.. 2023. 6. 8.
백준 27890 특별한 작은 분수 https://www.acmicpc.net/problem/27890 27890번: 특별한 작은 분수 첫 번째 줄에 $0$초에서의 분수의 높이 $x_0$와 $N$이 주어진다. $x_0$와 $N$은 모두 정수이다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 def solution(x, n): for i in range(n): if x % 2 == 0: x = int(x / 2) ^ 6 else: x = (2 * x) ^ 6 return x if __name__ == '__main__': x, n = map(int, input().split()) print(solution(x, n)) Colored by Color Scripter cs 2023. 6. 8.
백준 28113 정보섬의 대중교통 https://www.acmicpc.net/problem/28113 28113번: 정보섬의 대중교통 버스에 더 먼저 탑승할 수 있으면 Bus, 지하철에 더 먼저 탑승할 수 있으면 Subway, 버스와 지하철에 탑승하게 되는 시간이 동일하면 Anything을 출력한다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 def solution(n, a, b): if a == b: return 'Anything' elif a 2023. 6. 7.
leetcode 2652. Sum Multiples https://leetcode.com/problems/sum-multiples/description/ Sum Multiples - LeetCode Can you solve this real interview question? Sum Multiples - Given a positive integer n, find the sum of all integers in the range [1, n] inclusive that are divisible by 3, 5, or 7. Return an integer denoting the sum of all numbers in the given range satisf leetcode.com 1 2 3 4 5 6 7 8 class Solution(object): def su.. 2023. 5. 16.
백준 27959 초코바 https://www.acmicpc.net/problem/27959 27959번: 초코바 밤고는 $100$원 동전을 $N$개 갖고 있고, 그 돈으로 가격이 $M$원인 초코바를 사 먹으려고 한다. 밤고는 갖고 있는 돈으로 초코바를 사 먹을 수 있는지 알고 싶어 한다. 밤고가 가진 돈이 초코바의 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 dddddef sol(n, m): if n * 100 >= m: return 'Yes' else: return 'No' if __name__ == '__main__': n, m = map(int, input().split()) print(sol(n, m)) Colored by Color Scripter cs 2023. 4. 25.
leetcode 1431. Kids With the Greatest Number of Candies https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/description/ Kids With the Greatest Number of Candies - LeetCode Can you solve this real interview question? Kids With the Greatest Number of Candies - There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer extraCandie leetc.. 2023. 4. 17.
백준 27889 특별한 학교 이름 https://www.acmicpc.net/problem/27889 27889번: 특별한 학교 이름 GEC에는 여러 학교가 있다. 각 학교의 약칭과 정식 명칭은 다음과 같다. NLCS: North London Collegiate School BHA: Branksome Hall Asia KIS: Korea International School SJA: St. Johnsbury Academy 학교 이름을 좋아하는 규빈이 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 def sol(s): name = { 'NLCS':'North London Collegiate School', 'BHA': 'Branksome Hall Asia', 'KIS': 'Korea Internat.. 2023. 4. 4.