본문 바로가기

전체 글100

[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] 5678. 팰린드롬 https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWXRrK7KhO4DFAUo SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 재귀함수 호출을 이용하면 쉽게 구현 가능하다. 문자열 길이가 1보다 작거나 같을 때 최대 길이를 비교해서 업데이트 후 탈출하는 것이 포인트 def pal_check(s, depth): global max_len if len(s) 2021. 4. 4.
[Python] 13458. 시험 감독 https://www.acmicpc.net/problem/13458 13458번: 시험 감독 첫째 줄에 시험장의 개수 N(1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄에는 각 시험장에 있는 응시자의 수 Ai (1 ≤ Ai ≤ 1,000,000)가 주어진다. 셋째 줄에는 B와 C가 주어진다. (1 ≤ B, C ≤ 1,000,000) www.acmicpc.net N이 백만 이하이므로 loop로 전체 검사해준다. 단, A[i]보다 B가 크거나 같을 경우에는 건너뛴다. Task Score 100% Detected time complexity O(N) N = int(input()) A = list(map(int, input().split())) B, C = map(int, input().split()) .. 2021. 4. 4.
[Python] 3190. 뱀 https://www.acmicpc.net/problem/3190 3190번: 뱀 'Dummy' 라는 도스게임이 있다. 이 게임에는 뱀이 나와서 기어다니는데, 사과를 먹으면 뱀 길이가 늘어난다. 뱀이 이리저리 기어다니다가 벽 또는 자기자신의 몸과 부딪히면 게임이 끝난다. 게임 www.acmicpc.net 완탐실시하였다. 방향이 전환될 때의 좌표와 방향을 Queue에 저장하는 것이 포인트. Task Score 100% def solve(MAP): global N curr_head_y = curr_head_x = 0 curr_tail_y = curr_tail_x = 0 curr_head_di = 0 curr_tail_di = 0 turn_point = [] time = 0 while True: if time.. 2021. 4. 3.
[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] 6.4. Triangle https://app.codility.com/demo/results/trainingX6JCFR-MQJ/ Test results - Codility An array A consisting of N integers is given. A triplet (P, Q, R) is triangular if 0 ≤ P A[R], A[Q] + A[R] > A[P], A[R] + A[P] > A[Q]. For example, consider array A such that: A[0] = 10 A[1] = 2 A[2] = 5 A[3] = 1 A[4] = 8 A app.codility.com 인풋 데이터의 사이즈가 10만 아래이기 때문에 완전탐색하기로 결정하였다. 순열을.. 2021. 3. 26.
[Python] 6.3. NumberOfDiscIntersections https://app.codility.com/programmers/lessons/6-sorting/ 6. Sorting lesson - Learn to Code - Codility Maximize A[P] * A[Q] * A[R] for any triplet (P, Q, R). app.codility.com 1차시도 Task Score 50% Correctness 100% Performance 0% Detected time complexity O(N**2) def solution(A): cnt = 0 for i in range(len(A)): for j in range(i+1, len(A)): if max(A[j], A[i]) >= j-i or j-i 10 ** 7: return -1 return cnt 2021. 3. 25.
728x90
반응형