본문 바로가기
728x90

Python6

[code signal / 코드시그널] are Equally Strong ✨ Description Call two arms equally strong if the heaviest weights they each are able to lift are equal. Call two people equally strong if their strongest arms are equally strong (the strongest arm can be both the right and the left), and so are their weakest arms. Given your and your friend's arms' lifting capabilities find out if you two are equally strong. ✨ 문제 들어올릴 수 있는 가장 무거운 무게가 같으면 두 팔을 똑.. 2022. 5. 30.
[code signal / 코드시그널] Sort by height ✨ Description Some people are standing in a row in a park. There are trees between them which cannot be moved. Your task is to rearrange the people by their heights in a non-descending order without moving the trees. People can be very tall! ✨ 문제 몇몇 사람들이 공원에서 일렬로 서 있다. 그들 사이에는 움직일 수 없는 나무들이 있다. 당신의 임무는 나무를 움직이지 않고 사람들을 그들의 키에 따라 오름차순으로 정렬시키는 것이다. 사람들의 키가 매우 클 수 있다. 👉 배열에 -1로 주어진 나무의 위치는 변경시키지 않고.. 2022. 5. 30.
[code signal / 코드 시그널] alternatingSums ✨ Description Several people are standing in a row and need to be divided into two teams. The first person goes into team 1, the second goes into team 2, the third goes into team 1 again, the fourth into team 2, and so on. You are given an array of positive integers - the weights of the people. Return an array of two integers, where the first element is the total weight of team 1, and the second.. 2022. 5. 30.
[python] DFS(깊이우선탐색) / BFS(너비우선탐색) 1️⃣ DFS DFS는 Depth-First Search 깊이우선 탐색이라고 부르며 그래프에서 깊은 부분을 우선적으로 탐색하는 알고리즘이다. DFS 동작과정 탐색 시작 노드를 스택에 삽입하고 방문 처리를 한다 스택의 최상단 노드에 방문하지 않은 인접 노드가 있으면 그 인접 노드를 스택에 넣고 방문처리를 한다. 방문하지 않은 인접 노드가 없으면 스택에서 최상단 노드를 꺼낸다 2번의 과정을 더 이상 수행할 수 없을 때까지 반복한다. 인접행렬 : 2차원 배열로 그래프의 연결 관계를 표현하는 방식 예제 # 인접행렬 방식 예제 INF = 99999999 graph=[ [0,7,5], [7,0,INF], [5,INF,0] ] print(graph) 인접 리스트 : 리스트로 그래프의 연결 관계를 표현하는 방식👉 파이.. 2022. 5. 13.
728x90