분류 전체보기
-
87. 등장하지 않는 문자의 합Problem Solving 2023. 1. 18. 11:52
https://www.acmicpc.net/problem/3059 3059번: 등장하지 않는 문자의 합 입력은 T개의 테스트 데이터로 구성된다. 입력의 첫 번째 줄에는 입력 데이터의 수를 나타내는 정수 T가 주어진다. 각 테스트 데이터는 한 줄로 구성되어 있고, 문자열 S가 주어진다. S는 알파벳 www.acmicpc.net string에 포함되지 않는 알파벳의 아스키코드 값의 합을 구하는 문제 N = int(input()) for i in range(N): lis = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] answer = 0 str = input() fo..
-
86. 쉽게 푸는 문제Problem Solving 2023. 1. 18. 01:25
https://www.acmicpc.net/problem/1292 1292번: 쉽게 푸는 문제 첫째 줄에 구간의 시작과 끝을 나타내는 정수 A, B(1 ≤ A ≤ B ≤ 1,000)가 주어진다. 즉, 수열에서 A번째 숫자부터 B번째 숫자까지 합을 구하면 된다. www.acmicpc.net 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, .... 로 이어지는 수열에서 a번째 수부터 b번째 수까지의 합을 구하는 문제 a, b = map(int, input().split()) numbers = [] answer = 0 for i in range(1, 50): numbers = numbers + [i] * i for i in range(a, b + 1): answer = answer + numbers..
-
85. Min StackProblem Solving 2023. 1. 17. 23:51
https://leetcode.com/problems/min-stack/ Min Stack - LeetCode Min Stack - Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: * MinStack() initializes the stack object. * void push(int val) pushes the element val onto the stack. * void pop() leetcode.com 71. Implement Queue using Stacks와 비슷한 문제지만 queue가 아닌 stack을 구현하는 문제..
-
84. H-IndexProblem Solving 2023. 1. 15. 22:00
https://school.programmers.co.kr/learn/courses/30/lessons/42747 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr n개의 숫자 원소를 가진 배열을 입력받아 h 이상의 원소가 h개 이상일 때 h의 최댓값을 구하는 문제 def solution(citations): citations = sorted(citations, reverse=True) print(citations) for i in range(len(citations)): if i + 1 == citations[i]: return citations[i] if..
-
83. Maximum Units on a TruckProblem Solving 2023. 1. 15. 21:05
https://leetcode.com/problems/maximum-units-on-a-truck/description/ Maximum Units on a Truck - LeetCode Maximum Units on a Truck - You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]: * numberOfBoxesi is the number of boxes of type i. * numberOfUnitsPerBoxi leetcode.com [박수 개수, 박스 크기]의 리스트와 넣을 ..
-
82. 숫자놀이Problem Solving 2023. 1. 15. 20:42
https://www.acmicpc.net/problem/1755 1755번: 숫자놀이 79를 영어로 읽되 숫자 단위로 하나씩 읽는다면 "seven nine"이 된다. 80은 마찬가지로 "eight zero"라고 읽는다. 79는 80보다 작지만, 영어로 숫자 하나씩 읽는다면 "eight zero"가 "seven nine"보다 사전순으로 www.acmicpc.net 범위의 처음과 끝을 integer로 받아 범위 내 숫자 각각을 영어로 변환해 알파벳 순으로 정렬 start, last = input().split() numbslist = [i for i in range(int(start), int(last) + 1)] newn = {} for i in numbslist: numbstr = "" for j in..
-
81. 접미사 배열Problem Solving 2023. 1. 15. 19:50
https://www.acmicpc.net/problem/11656 11656번: 접미사 배열 첫째 줄에 문자열 S가 주어진다. S는 알파벳 소문자로만 이루어져 있고, 길이는 1,000보다 작거나 같다. www.acmicpc.net 입력받은 string에서 앞의 n(1~len(string) -1)글자를 뗀 string들의 리스트를 정렬 string = input() stringli = [string[i:] for i in range(len(string) - 1)] stringli.append(string[-1]) stringli = sorted(stringli) for i in stringli: print(i)
-
80. 중복 빼고 정렬하기Problem Solving 2023. 1. 15. 19:41
https://www.acmicpc.net/problem/10867 10867번: 중복 빼고 정렬하기 첫째 줄에 수의 개수 N (1 ≤ N ≤ 100,000)이 주어진다. 둘째에는 숫자가 주어진다. 이 수는 절댓값이 1,000보다 작거나 같은 정수이다. www.acmicpc.net 입력받은 수에서 중복을 빼고 오름차순으로 정렬 N = int(input()) numbers = {int(i):"" for i in input().split()} numbers = sorted(numbers.keys()) print(" ".join(map(str, numbers)))