일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- node.js로 로그인하기
- Do it 자바스크립트 + 제이쿼리 입문
- intllij 내 Bean을 찾지 못해서 발생하는 오류
- 인프런
- react오류
- 모던자바스크립트
- props
- 거북이 대포 게임
- 리액트
- spring-boot
- Concurrently
- Spring-Framework
- DB Browser
- react
- intellij
- 타자 게임 만들기
- Python
- node.js 설치
- Colaboratory 글자 깨짐
- vs code 내 node
- 노드에 리액트 추가하기
- JS 개념
- 자바스크립트
- 따라하며 배우는 노드 리액트 기본 강의
- googleColaboratory
- 웹 게임을 만들며 배우는 리액트
- ReactDOM.render is no longer supported in React 18. Use createRoot instead
- 계산맞추기 게임
- 모두의 파이썬
- You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client"
- Today
- Total
프로그래밍 삽질 중
[백준] python 코딩테스트 - 배열(10818, 2953, 1158) 본문
출처 : http://www.yes24.com/Product/Goods/107478270
보통의 취준생을 위한 코딩 테스트 with 파이썬 - YES24
이 책은 손에 잡히는 코딩 테스트 합격 방법을 제시한다. 바로 “백준 플래티넘 5 & 코드 포스 파란색 랭크”로 목표 설정을 구체화한 것이다. 이 수준을 달성하면 웬만한 기업의 코딩 테스트 문
www.yes24.com
* 최소, 최대(10818)
https://www.acmicpc.net/problem/10818
10818번: 최소, 최대
첫째 줄에 정수의 개수 N (1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄에는 N개의 정수를 공백으로 구분해서 주어진다. 모든 정수는 -1,000,000보다 크거나 같고, 1,000,000보다 작거나 같은 정수이다.
www.acmicpc.net
array_list = list(map(int, input().split()))
# 최댓값과 최소값 저장하기 위한 변수
max_num = array_list[0]
min_num = array_list[0]
for num in array_list:
if num > max_num:
max_num = num
if num < min_num:
min_num = num
print(min_num, max_num)
* 나는 요리사다(2953)
https://www.acmicpc.net/problem/2953
2953번: 나는 요리사다
"나는 요리사다"는 다섯 참가자들이 서로의 요리 실력을 뽐내는 티비 프로이다. 각 참가자는 자신있는 음식을 하나씩 만들어오고, 서로 다른 사람의 음식을 점수로 평가해준다. 점수는 1점부터 5
www.acmicpc.net
human = [list(map(int, input().split())) for _ in range(5)]
# print(human) #[[5, 4, 4, 5], [5, 4, 4, 4], [5, 5, 4, 4], [5, 5, 5, 4], [4, 4, 4, 5]]
humanScore = [0]*5 # 참가자들의 총합 점수를 구하기 위함
# print(humanScore) #[0, 0, 0, 0, 0]
score = 0 # 최대 점수 저장
for i in range(5):
sum = 0
for j in range(4):
sum += human[i][j]
# print("sum", sum) # 5 9 13 18 | 5 10 14 18 | 5 10 15 19 | 4 8 12 17
humanScore[i] = sum # 각 참가자가 받은 점수 합들
#print("ResultSum", humanScore[i])
score = max(score, sum) # 18 17 18 19 17 => 19
# print("score", score) # 점수 합들 중 최댓값 표시
for i in range(5):
# print("humanScore[i]", humanScore[i]) #18 17 18 19
if humanScore[i] == score:
print(i+1, score) #자릿수 = i + 1
break
* 요세푸스 문제 (1158)
https://www.acmicpc.net/problem/1158
1158번: 요세푸스 문제
첫째 줄에 N과 K가 빈 칸을 사이에 두고 순서대로 주어진다. (1 ≤ K ≤ N ≤ 5,000)
www.acmicpc.net
- 배열의 삽입과 삭제가 빈번할 때 시간 복잡도에 유의하며 사용해야 함
* 클래스란?
▶ 클래스 구성을 이용
▶ 글로벌 변수를 없애고, 모든 변수를 어떤 스코프에 소속시킴
▶ 몇 번이고 재사용 가능
▶ 코드 수정 최소화
▶ 함수 실행 중에 함수 자신을 다시 호출 가능
* __init__이란?
▶ 컨스트럭터라고 불리는 초기화를 위한 함수(메소드)
▶ 인스턴스화 실행 시 반드시 처음에 호출되는 함수
▶ 오브젝트 생성(인스턴스 생성)과 관련해 데이터 초기를 실시하는 함수
▶ 반드시 첫 번째 인수로 self를 지정해야 함 (self에는 인스턴스 자체가 전달 되어있음)
참고 : https://engineer-mole.tistory.com/190
[python] python의 self와 __init__의 이해
※ 일본의 한 포스팅을 번역한 글입니다. 오역 및 직역이 있을 수 있으며, 내용 오류는 댓글로 지적해주심 감사하겠습니다. Python의 클래스에 대한 이해 다른 언어와 동일하게 python에서도 클래스
engineer-mole.tistory.com
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self, value):
self.head = Node(value)
def insert(self, value):
cur = self.head
while cur.next is not None:
cur = cur.next
cur.next = Node(value)
def get_node(self, index):
node = self.head
count = 0
while count < index:
count += 1
node = node.next
return node
def delete_Node(self, index):
if index == 0:
del_node = self.head.data
self.head = self.head.next
return del_node
node = self.get_node(index - 1)
del_node = node.next.data
node.next = node.next.next
return del_node
N, K = map(int, input().split())
Link = LinkedList(1)
for i in range(2, N+1):
Link.insert(i)
answer = []
idx = K - 1
while Link.head is not None:
idx %= N
answer.append(Link.delete_Node(idx))
idx += (K - 1)
N -= 1
print("<", end="")
for i in range(len(answer) - 1):
print(answer[i], end=", ")
print(answer[len(answer) - 1], end="")
print(">")
'과거 프로그래밍 자료들 > 코딩테스트' 카테고리의 다른 글
[백준] python 코딩테스트 - 큐(18258, 2164, 3190) (0) | 2022.09.29 |
---|---|
[백준] python 코딩테스트 - 스택(10828, 10799, 2812) (1) | 2022.09.22 |
[백준] python 코딩테스트 - 기초(10869, 1330, 2438, 2439, 2442) (0) | 2022.09.19 |
[자바스크립트] 프로그래머스 - 핸드폰 번호 가리기 (0) | 2022.06.23 |
[자바스크립트] 프로그래머스 - 행렬의 덧셈 (0) | 2022.06.23 |