본문 바로가기

Problem Solving/Programmers13

[BFS] Python 43162 네트워크 https://school.programmers.co.kr/learn/courses/30/lessons/43162 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr from collections import deque def solution(n, computers): answer = 0 # 네트워크의 개수 visited = [0] * n # 컴퓨터의 개수: n def BFS(start): q = deque([start]) while q: tmp = q.popleft() visited[tmp] = 1 # 꺼낸 후 방문하기 for i in range(len(co.. 2023. 5. 30.
[Sorting] Python 42577 전화번호 목록 https://school.programmers.co.kr/learn/courses/30/lessons/42577 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr # 2023.04.18 def solution(phone_book): answer = True # 접두어가 없으면 true phone_book.sort() length = len(phone_book) for i in range(length - 1): if phone_book[i] == phone_book[i + 1][:len(phone_book[i])]: answer = False break re.. 2023. 4. 18.
[구현] 프로그래머스 136798 기사단원의 무기 https://school.programmers.co.kr/learn/courses/30/lessons/136798 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(number, limit, power): answer = 0 for i in range(1, number+1): tmp = 0 # 해당 수의 약수의 개수를 count for j in range(1, int(i**0.5)+1): if i%j == 0: # 약수라면 if j == i//j: # 제곱근이라면 tmp += 1 else: # 제곱근이 아닐 경우 tmp += 2 if.. 2023. 3. 21.
[SQL] 프로그래머스 join 59043 https://school.programmers.co.kr/learn/courses/30/lessons/59043 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr select o.animal_id, o.name from animal_ins i inner join animal_outs o where i.animal_id = o.animal_id and i.datetime>o.datetime order by i.datetime 2023. 2. 23.