본문 바로가기

Stack7

[Python] DisappearingPairs https://app.codility.com/demo/results/trainingFRJG6A-A4D/ Test results - Codility A string S containing only the letters "A", "B" and "C" is given. The string can be transformed by removing one occurrence of "AA", "BB" or "CC". Transformation of the string is the process of removing letters from it, based on the rules described above. A app.codility.com Point 전형적인 stack과 관련된 알고리즘 입력값과 stack의 가장 .. 2021. 7. 15.
[Python] Leader https://codility.com/media/train/6-Leader.pdf Leader는 크기 N인 배열A 에서 과반수 이상 (N//2+1) 의 갯수를 가지고 있는 요소를 말한다. Leader를 조사하는 방법을 아래와 같이 정리하였다. 1. Sorting 정렬 후 중앙값의 카운트를 계산한다. 카운트가 n//2 보다 크다면 Leader에 해당한다. Detected time complexity O(N * log(N)) def solution(A): n = len(A) s_A = sorted(A) leader = None count = 0 for i in range(n): if s_A[i] == s_A[n//2]: count += 1 if count > n // 2: leader = s_A[n//2] .. 2021. 4. 5.
[Python] 8.1. Dominator https://app.codility.com/demo/results/trainingKJKX8S-C3B/ Test results - Codility An array A consisting of N integers is given. The dominator of array A is the value that occurs in more than half of the elements of A. For example, consider array A such that A[0] = 3 A[1] = 4 A[2] = 3 A[3] = 2 A[4] = 3 A[5] = -1 A[6] = 3 A[7] = 3 The dom app.codility.com Task Score 100% Correctness 100% Performan.. 2021. 4. 5.
[Python] 7.3. Nesting app.codility.com/demo/results/training6WQ7HN-NGN/ Test results - Codility A string S consisting of N characters is called properly nested if: S is empty; S has the form "(U)" where U is a properly nested string; S has the form "VW" where V and W are properly nested strings. For example, string "(()(())())" is properly nested but app.codility.com Task Score 100% Correctness 100% Performance 100% .. 2021. 3. 30.
[Python] 7.2. Fish app.codility.com/demo/results/trainingWVD5AJ-4CG/ Test results - Codility You are given two non-empty arrays A and B consisting of N integers. Arrays A and B represent N voracious fish in a river, ordered downstream along the flow of the river. The fish are numbered from 0 to N − 1. If P and Q are two fish and P < Q, then fish app.codility.com Task Score 100% Correctness 100% Performance 100% De.. 2021. 3. 29.
[Python] 7.1. Brackets https://app.codility.com/demo/results/trainingU6MG2S-N29/ Test results - Codility A string S consisting of N characters is considered to be properly nested if any of the following conditions is true: S is empty; S has the form "(U)" or "[U]" or "{U}" where U is a properly nested string; S has the form "VW" where V and W are properly nes app.codility.com Task Score 100% Correctness 100% Performan.. 2021. 3. 27.
[Python]13460. 구슬 탈출 2 https://www.acmicpc.net/problem/13460 13460번: 구슬 탈출 2 첫 번째 줄에는 보드의 세로, 가로 크기를 의미하는 두 정수 N, M (3 ≤ N, M ≤ 10)이 주어진다. 다음 N개의 줄에 보드의 모양을 나타내는 길이 M의 문자열이 주어진다. 이 문자열은 '.', '#', 'O', 'R', 'B' 로 이루어져 있다. '.'은 빈 칸을 의미하고, '#'은 공이 이동할 수 없는 장애물 또는 벽을 의미하며, 'O'는 구멍의 위치를 의미한다. 'R'은 빨간 구슬의 위치, 'B'는 파란 구슬의 위치이다. 입력되는 모든 보드 www.acmicpc.net 어느 방향으로 기울이는가에 따라 queue에 Red와 Blue의 좌표를 초기화 해주어야 한다.(중요!) 또한 현재 Red 와 B.. 2019. 5. 10.
728x90
반응형