Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions UiHyeon/week_3/array_turn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
def solution(rows, columns, queries):
answer = []
graph = []
num = 1
#ํ–‰๋ ฌ ์ƒ์„ฑ
for i in range(rows):
temp = []
for j in range(columns):
temp.append(num)
num += 1

graph.append(temp)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋งŒ๋“ ๋‹ค๋ฉด ํ•œ์ค„๋กœ๋„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์ง€ ์•Š์„๊นŒ์š”?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ฝ”๋“œ๊ฐ€ ์งง์•„๋ณด์ด๋Š” ํšจ๊ณผ๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ๊ฒ ๋„ค์š”


for i in range(len(queries)):
base_r, base_c = queries[i][0], queries[i][1]
end_r, end_c = queries[i][2], queries[i][3]
slave = graph[base_r-1][end_c-1]
mini = slave
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slave๋Š” ๋ฌด์Šจ ์˜๋ฏธ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‚˜์š”?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„ ์ด๊ฑด ์ˆซ์ž๋ฅผ ์ด๋™ํ•˜๋‹ค ๋ณด๋ฉด ์ฒ˜์Œ ์ด๋™์‹œํ‚จ ์ˆซ์ž๊ฐ€ ํšŒ์ „๋ฌธ์—์„œ ์ œ์™ธ๋˜๋Š”๋ฐ ์ด ์ˆซ์ž๋ฅผ ๋งˆ์ง€๋ง‰์ด๋™ ์ž๋ฆฌ์— ๋‹ค์‹œ ๋ผ์›Œ๋„ฃ์–ด์ค˜์•ผํ•ฉ๋‹ˆ๋‹ค . ๊ทธ๋ž˜์„œ slave๋ผ๋Š” ๋ณ€์ˆ˜๋กœ ๊ฐ’์„ ์ €์žฅํ–ˆ์Šต๋‹ˆ๋‹ค.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ณ€์ˆ˜๋ช…์ด ์ฒ˜์Œ ๋ณด๋Š” ์‚ฌ๋žŒ์ด ์•Œ์•„๋ณด๊ธฐ ์–ด๋ ค์›Œ์š” ใ… ใ…  ๋” ๊ฐ€๋…์„ฑ ์žˆ๋Š” ๋ณ€์ˆ˜๋ช…์„ ์จ๋ณด์ž์š”~~!

Copy link
Copy Markdown
Collaborator Author

@UiHyeon UiHyeon Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„ใ…‹ใ…‹ใ…‹ ๋งž์Šต๋‹ˆ๋‹ค ใ…‹ใ…‹ใ…‹ ๊ฐœ๊ทธ ์†Œ์žฌ๋กœ ์‚ฌ์šฉํ–ˆ๋Š”๋ฐ ๋ณ€๊ฒฝํ• ๊ฒŒ์š” XD


#์ƒ
for j in range(end_c-1, base_c-1, -1):
temp = graph[base_r-1][j-1]
graph[base_r-1][j] = temp
mini = min(temp, mini)
#์ขŒ
for j in range(base_r-1, end_r-1):
temp = graph[j+1][base_c-1]
graph[j][base_c-1] = temp
mini = min(temp, mini)
#ํ•˜
for j in range(base_c-1, end_c-1):
temp = graph[end_r-1][j+1]
graph[end_r-1][j] = temp
mini = min(temp, mini)
#์šฐ
for j in range(end_r-1, base_r-1, -1):
temp = graph[j-1][end_c-1]
graph[j][end_c-1] = temp
mini = min(temp, mini)

graph[base_r][end_c-1] = slave
answer.append(mini)

return answer
36 changes: 36 additions & 0 deletions UiHyeon/week_3/bracket_turn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from collections import deque

def right(deq):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right๋„ ์ข‹์ง€๋งŒ string์ด ๊ด„ํ˜ธ ๊ฒ€์‚ฌ๋กœ ๋ถ€ํ„ฐ validํ•œ์ง€๋ฅผ ํ™•์ธํ•˜๋Š” ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— isValidBracket๊ณผ ๊ฐ™์ด is๋ฅผ ์•ž์— ๋ถ™์—ฌ์ฃผ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋„ค์š”.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ข‹์€ ํ•จ์ˆ˜ ๋ช…๋ช…๋ฒ• ๋ฐฐ์›Œ๊ฐ‘๋‹ˆ๋‹ค!

stack = []
for check in deq:
if check == '(' or check == '{' or check == '[':
stack.append(check)
if stack:
if check == ')' and stack.pop() != '(':
return False
if check == '}' and stack.pop() != '{':
return False
if check == ']' and stack.pop() != '[':
return False
else: return False
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด๋ถ€๋ถ„์€ ์ •๊ทœํ‘œํ˜„์‹์œผ๋กœ๋„ ํ•œ๋ฒˆ ์งœ๋ณด๊ธฐ๋ฅผ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค ใ…Žใ…Ž ๋ฌผ๋ก  ์งœ๋Š” ์†๋„๋Š” if ๋ฌธ์„ ์“ฐ๋Š”๊ฒŒ ๋น ๋ฅด๊ฒ ์ฃ ?


if stack: return False

return True

def solution(s):
answer = -1
deq = deque(_ for _ in s)
print(deq)
count = 0

for i in range(len(s)):
if right(deq):
count += 1

deq.append(deq.popleft())

if count > 1:
return count
else:
return 0