Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nerdenrd/Algorithm_study
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: shstat1729/Algorithm_study
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
Showing with 1,841 additions and 7 deletions.
  1. +15 −0 .github/ISSUE_TEMPLATE/-------------.md
  2. +15 −0 .github/ISSUE_TEMPLATE/------.md
  3. +9 −0 .github/PULL_REQUEST_TEMPLATE.md
  4. +7 −0 .gitignore
  5. +21 −7 README.md
  6. +62 −0 code/SanghoPark94/.ipynb_checkpoints/1417problemqueue-checkpoint.ipynb
  7. +35 −0 code/SanghoPark94/1417problem.py
  8. +62 −0 code/SanghoPark94/1417problemqueue.ipynb
  9. +43 −0 code/SanghoPark94/Greedy_problem_1.py
  10. +25 −0 code/SanghoPark94/printer.py
  11. +18 −0 code/jina/Stack/괄호(백준).py
  12. +17 −0 code/jina/Stack/탑(백준).py
  13. +28 −0 code/jina/queue/다리를 지나는 트럭.py
  14. +23 −0 code/jina/queue/프린터.py
  15. +49 −0 code/jina/sorting/11004번 K번째 수.py
  16. +21 −0 code/jina/sorting/2750번 버블정렬.py
  17. +35 −0 code/jina/sorting/2750번 삽입정렬.py
  18. +28 −0 code/jina/sorting/2750번 선택정렬.py
  19. +64 −0 code/jina/sorting/2751번 수 정렬하기2.py
  20. +36 −0 code/jina/sorting/5525번 IOIOI.py
  21. +64 −0 code/jina/재귀/11729번 하노이의탑이동순서.py
  22. +31 −0 code/jina/재귀/별찍기-10.py
  23. +33 −0 code/junho/stack1.py
  24. +37 −0 code/nerdchanii/sort/2750_bubble.py
  25. +41 −0 code/nerdchanii/sort/2750_shaker.py
  26. +46 −0 code/nerdchanii/stack/백준(괄호).py
  27. +30 −0 code/nerdchanii/재귀/하노이의탑이동순서.py
  28. +33 −0 code/shinn92kr/stack&queue/프로그래머스_기능개발.py
  29. +26 −0 code/shinn92kr/stack&queue/프로그래머스_다리를지나는트럭.py
  30. +29 −0 code/shinn92kr/stack&queue/프로그래머스_주식가격.py
  31. +29 −0 code/shinn92kr/stack&queue/프로그래머스_프린터.py
  32. +19 −0 code/sungtae/binarysearch/finding_tree.py
  33. +29 −0 code/sungtae/queue/프로그래머스 기능개발.py
  34. +32 −0 code/sungtae/queue/프로그래머스 프린터.py
  35. +12 −0 code/sungtae/recursion/11729 하노이의 탑 이동순서.py
  36. +36 −0 code/sungtae/recursion/2447 별 찍기 10.py
  37. +26 −0 code/sungtae/stack/백준 9012번 VPS.py
  38. +23 −0 code/vg-rlo/stack and queue/baekjoon_2493.py
  39. +42 −0 code/vg-rlo/stack and queue/baekjoon_9012.py
  40. +27 −0 code/승환/스택/baekjoon2493_top.py
  41. +17 −0 code/승환/스택/baekjoon9012_bracket.py
  42. +197 −0 스택과큐/queue.md
  43. +135 −0 스택과큐/stack.md
  44. +80 −0 재귀알고리즘/재귀알고리즘.md
  45. +154 −0 정렬알고리즘/정렬알고리즘.md
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/-------------.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: 내용 수정이 필요할 경우
about: 내용을 바꾸어야할 떄 사용하는 템플릿입니다.
title: "[내용수정]"
labels: Change Docs
assignees: nerdchanii, vg-rlo

---

## 위치:

## 수정전 내용


##수정후 내용
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/------.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: '오탈자수정 '
about: 오탈자 수정이 필요합니다.
title: "[오탈자 수정]"
labels: Modify
assignees: nerdchanii, vg-rlo

---

## 파일명:

## 변경전 내용(변경해야 할 내용)


## 변경후 내용(변경이 반영된 내용)
9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## 푼 문제:
### 문제: [문제이름](링크)

### 담당리뷰어
- reviewer :

### 특이사항


7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
code/nerdchanii/stack/.idea/misc.xml
code/nerdchanii/stack/.idea/modules.xml
code/nerdchanii/stack/.idea/stack.iml
code/nerdchanii/stack/.idea/vcs.xml
code/nerdchanii/stack/.idea/workspace.xml
code/nerdchanii/stack/.idea/inspectionProfiles/profiles_settings.xml
code/nerdchanii/stack/.idea/inspectionProfiles/profiles_settings.xml
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# [Algorithm_study](https://github.com/narongchan/Algorithm_study)

>This repository for Keep going study Group. We study Algorithm, data Structure using python.
>This repository for the Keep going study Group. We study Algorithm, data Structure using python.
이 레포지토리는 **DO it: 자료구조와 함께 배우는 알고리즘 입문 python** 을 스터디하며, 정리한 저장소입니다.
이 레포지토리는 ***[DO it: 자료구조와 함께 배우는 알고리즘 입문 python](https://github.com/easyIT/doit_dsalgo_with_python)*** 을 스터디하며, 정리한 저장소입니다.

문제의 소지가 되는 부분이 생길 경우, 문제소지의 부분은 삭제, 혹은 수정하도록 하겠습니다.
#### [문제풀이 관련 안내사항](code/CODE_README.md)을 꼭 참고해주세요!
이 저장소의 요약은 ["easyIT"]("https://github.com/easyIT)의 허락을 받고 진행했습니다.
- [저작권허락 내용]("https://github.com/easysIT/doit_dsalgo_with_python/issues/2")

문제의 소지가 되는 부분이 생길 경우, 문제소지의 부분을 즉시 삭제, 혹은 수정하도록 하겠습니다.

#### [문제풀이 관련 안내사항](code/CODE_README.md "문제풀이 관련 안내사항")을 꼭 참고해주세요!

## [검색알고리즘](검색알고리즘/)
### [linearSearch(선형검색)](검색알고리즘/linearSearch.md)
@@ -16,8 +20,18 @@
### [linearSearch(해쉬법)](검색알고리즘/hashSearch.md)


## Contirubutor
### **스터디에 참여한사람들** (계속 해서 추가하도록하겠습니다.)
## [재귀알고리즘](재귀알고리즘/재귀알고리즘.md)

## [정렬알고리즘](정렬알고리즘/정렬알고리즘.md)


## Study Member✨
### **스터디에 참여한 사람들** (계속 해서 추가하도록하겠습니다.)


- [vg-rlo](https://www.github.com/vg-rlo "vg-rlo의 Github")
- [narongchan](https://www.github.com/vg-rlo "narongchan의 Github")
- [nerdchanii](https://www.github.com/vg-rlo "narongchan의 Github")
- [stae1102](https://www.github.com/stae1102 "stae1102의 Github")
- [mango-jina](https://www.github.com/mango-jina "puro의 Github")
- [yureka0920](https://www.github.com/yureka0920 "yereka0920의 Github")
- [shinn92kr](https://www.github.com/shinn92kr "shinn92kr Github")
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "7286e986-5a1a-46e3-88e8-1f2fd0b0d6f0",
"metadata": {},
"outputs": [],
"source": [
"def solve(input_list : list) -> int:\n",
" dasom=input_list[0] \n",
" compe=input_list[1:N]\n",
" compe=sorted(compe,reverse=True)\n",
" cnt=0\n",
" \n",
" if N==1:\n",
" print(cnt)\n",
" \n",
" else:\n",
" while dasom<=compe[0]:\n",
" dasom+=1\n",
" compe[0]-=1\n",
" compe=sorted(compe,reverse=True)\n",
" cnt+=1\n",
" \n",
" print(cnt)\n",
"\n",
" \n",
"if __name__=='__main__':\n",
" \n",
" N=int(input())\n",
" vote_list=[]\n",
" \n",
" for i in range(N):\n",
" vote_list.append(int(input()))\n",
" \n",
" solve(vote_list)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
35 changes: 35 additions & 0 deletions code/SanghoPark94/1417problem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


def solve(input_list : list) -> int:
dasom=input_list[0]
compe=input_list[1:N]
compe=sorted(compe,reverse=True)
cnt=0

if N==1:
print(cnt)

else:
while dasom<=compe[0]:
dasom+=1
compe[0]-=1
compe=sorted(compe,reverse=True)
cnt+=1

print(cnt)


if __name__=='__main__':

N=int(input())
vote_list=[]

for i in range(N):
vote_list.append(int(input()))

solve(vote_list)

62 changes: 62 additions & 0 deletions code/SanghoPark94/1417problemqueue.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "7286e986-5a1a-46e3-88e8-1f2fd0b0d6f0",
"metadata": {},
"outputs": [],
"source": [
"def solve(input_list : list) -> int:\n",
" dasom=input_list[0] \n",
" compe=input_list[1:N]\n",
" compe=sorted(compe,reverse=True)\n",
" cnt=0\n",
" \n",
" if N==1:\n",
" print(cnt)\n",
" \n",
" else:\n",
" while dasom<=compe[0]:\n",
" dasom+=1\n",
" compe[0]-=1\n",
" compe=sorted(compe,reverse=True)\n",
" cnt+=1\n",
" \n",
" print(cnt)\n",
"\n",
" \n",
"if __name__=='__main__':\n",
" \n",
" N=int(input())\n",
" vote_list=[]\n",
" \n",
" for i in range(N):\n",
" vote_list.append(int(input()))\n",
" \n",
" solve(vote_list)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
43 changes: 43 additions & 0 deletions code/SanghoPark94/Greedy_problem_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


from collections import Counter

def solution(n, lost, reserve):

stu = dict()
for i in range(1, n+1):
stu[i] = 1

for i in lost:
stu[i] = stu.get(i)-1

for i in reserve:
stu[i] = stu.get(i)+1

for k, v in stu.items():
if v==0:
if k==1 and stu[k+1]==2:
stu[k+1]=stu.get(k+1)-1
stu[k]=stu.get(k)+1


elif k!=1 and k!=n:
if stu[k-1]==2:
stu[k-1]=stu.get(k-1)-1
stu[k]=stu.get(k)+1

elif stu[k+1]==2:
stu[k+1]=stu.get(k+1)-1
stu[k]=stu.get(k)+1


elif k==n and stu[k-1]==2:
stu[k-1]=stu.get(k-1)-1
stu[k]=stu.get(k)+1
stu=Counter(stu.values())
return n-stu[0]

25 changes: 25 additions & 0 deletions code/SanghoPark94/printer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python
# coding: utf-8

# In[19]:


from collections import deque
def solution(priorities : list, location : int) -> int:
answer=0
leng=len(priorities)
ans_list= deque(list(range(leng)))
ordered_list=[]
priorities=deque(priorities)

while len(ans_list)!=0:
if priorities[0]<max(priorities):
priorities.append(priorities.popleft())
ans_list.append(ans_list.popleft())

else:
ordered_list.append(ans_list.popleft())
priorities.popleft()
answer= ordered_list.index(location)+1
return answer

18 changes: 18 additions & 0 deletions code/jina/Stack/괄호(백준).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import sys
n = int(input()) # 입력 데이터 수
for _ in range(n):
data = sys.stdin.readline().strip()
if len(data) % 2 != 0: # data 길이가 홀수라면 올바른 괄호 문자열이 될 수 없으므로 무조건 'NO' print
print('NO')
continue
stack = [] # data길이가 짝수라면 stack을 만들어서 판단
while len(data) != 0:
if len(stack) != 0 and stack[-1] == '(' and data[0] == ')': # stack의 맨 끝 값이 '('이고 stack에 들어갈 값이 ')'인 경우 올바른 괄호 문자열이므로 stack의 끝 값을 제거
stack.pop()
else: # 그렇지 않은 경우 stack에 data 첫 문자 추가
stack.append(data[0])
data = data[1:] # data의 다음 문자를 판단하기 위해 슬라이싱
if len(stack) == 0: # 모든 과정 후 stack에 아무런 값도 없다면 올바른 괄호 문자열
print('YES')
else: # stack에 값이 남아 있다면 올바르지 않은 괄호 문자열
print('NO')
17 changes: 17 additions & 0 deletions code/jina/Stack/탑(백준).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
N = int(input()) # 입력 데이터 개수
tops = list(map(int,input().split())) # 공백 기준으로 리스트 만들기
answer = [0] # 첫 번째 탑은 레이저를 수신받을 탑이 없으므로 0 출력
stack = [[0,tops[0]]]
for i in range(1, N): # 두 번째 탑부터 왼쪽 탑들이 레이저를 수신하는지 판단
while stack:
if stack[-1][1] > tops[i]: # stack[-1][1]값이 tops[i]보다 크거나 같으면 레이저를 수신
answer.append(stack[-1][0]+1) # 레이저를 수신하는 탑의 번호를 answer에 추가하고 break
break
else: # stack[-1][1]값이 tops[i]보다 작으면 레이저를 수신하지 못하므로 stack에서 제거
stack.pop()
if len(stack) == 0: # stack에 값이 없으면 아무 탑도 레이저를 수신하지 못하므로 0 출력
answer.append(0)
break
stack.append([i,tops[i]])

print(' '.join(map(str,answer))) # 공백을 추가해서 출력
28 changes: 28 additions & 0 deletions code/jina/queue/다리를 지나는 트럭.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
def solution(bridge_length, weight, truck_weights):
time = 0

# 트럭이 다리를 건너는 상황을 bridge로 표현하기 위해 bridge_length만큼 배열을 만들어줌
bridge = [0] * bridge_length

# bridge에 트럭이 존재하는 동안 while루프를 돌게 함
while bridge:

# 1초일 때 첫 번째 트럭이 bridge에 올라옴
time += 1

# 1초마다 트럭은 이동하므로 맨 앞의 트럭은 1초가 지나면 다리를 지난 트럭이므로 제거
bridge.pop(0)

# truck_weigths에 들어있는 트럭들을 bridge로 올리기
if len(truck_weights) != 0:

# bridge위에 올라와있는 트럭의 총 무게와 새로 bridge에 올라올 트럭의 무게의 합을 다리가 견딜 수 있는 무게 weight와 비교
# weight값보다 작거나 같으면 bridge에 새로운 트럭 추가
if sum(bridge) + truck_weights[0] <= weight:
bridge.append(truck_weights.pop(0))

# weight값보다 크면 bridge에 올라올 수 없으므로 0 추가
else:
bridge.append(0)

return time
Loading