자료구조 & 알고리즘 관련

https://www.acmicpc.net/problem/1012 1012번: 유기농 배추 차세대 영농인 한나는 강원도 고랭지에서 유기농 배추를 재배하기로 하였다. 농약을 쓰지 않고 배추를 재배하려면 배추를 해충으로부터 보호하는 것이 중요하기 때문에, 한나는 해충 방지에 www.acmicpc.net import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int[] dx= {1, 0, -1, 0}; static int[] dy= {0, 1, 0, -1}; static int[][] arr; public static void main(Str..
https://www.acmicpc.net/problem/2108 2108번: 통계학 첫째 줄에 수의 개수 N(1 ≤ N ≤ 500,000)이 주어진다. 단, N은 홀수이다. 그 다음 N개의 줄에는 정수들이 주어진다. 입력되는 정수의 절댓값은 4,000을 넘지 않는다. www.acmicpc.net 처음 풀이 import sys from collections import Counter n = int(sys.stdin.readline()) numbers = [] for _ in range(n): numbers.append(int(sys.stdin.readline())) # 산술평균 print(round(sum(numbers) / n)) # 중앙값 numbers.sort() print(numbers[n // ..
https://www.acmicpc.net/problem/1427 1427번: 소트인사이드 첫째 줄에 정렬하려고 하는 수 N이 주어진다. N은 1,000,000,000보다 작거나 같은 자연수이다. www.acmicpc.net input_number = input() # 입력 input_list = list(map(int, list(input_number))) # list 변환 -> int형으로 변환 -> 다시 list로 input_list.sort(reverse=True) # 내림차순 정렬 for i in input_list: # 출력 print(i, end='') import java.io.BufferedReader; import java.io.IOException; import java.io.Inpu..
https://school.programmers.co.kr/learn/courses/30/lessons/132267 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(a, b, n): answer = 0 while a
https://leetcode.com/problems/design-browser-history/ Design Browser History - LeetCode Design Browser History - You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: * BrowserHisto leetcode.com 파이썬 코드 더보기 class ListNode(object): def _..
https://school.programmers.co.kr/learn/courses/30/lessons/42578# 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(clothes): answer = 1 clothes_dict = dict() for c in clothes: item = c[-1] for i in range(len(c) - 2, -1, -1): if item not in clothes_dict: clothes_dict[item] = set() clothes_dict[item].add(c[i]) for key in clo..
솜사탕코튼
'자료구조 & 알고리즘 관련' 카테고리의 글 목록 (4 Page)