본문 바로가기

분류 전체보기100

[Python] 6.2. MaxProductOfThree 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 Task Score 100% Correctness 100% Performance 100% Detected time complexity O(N * log(N)) def solution(A): _A = sorted(A) return max(_A[0]*_A[1]*_A[-1], _A[-3]*_A[-2]*_A[-1]) 2021. 3. 25.
[Python] 6.1. Distinct 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 Task Score 100% Correctness 100% Performance 100% Time Complexity O(N*log(N)) or O(N) def solution(A): return len(set(A)) 2021. 3. 25.
[Python] 5.4. PassingCars https://app.codility.com/programmers/lessons/5-prefix_sums/ 5. Prefix Sums lesson - Learn to Code - Codility Compute number of integers divisible by k in range [a..b]. app.codility.com Task Score 100% Correctness 100% Performance 100% 시간복잡도 O(N) def solution(A): east = [] for i in range(len(A)): if A[i] == 0: east.append(i) if len(east) == 0: return 0 prefix_sum = [] for i in range(len(east)-1):.. 2021. 3. 24.
[Python] 5.3. MinAvgTwoSlice https://app.codility.com/programmers/lessons/5-prefix_sums/ 5. Prefix Sums lesson - Learn to Code - Codility Compute number of integers divisible by k in range [a..b]. app.codility.com 1차 시도 Task Score 50% Correctness 100% Performance 0% 시간복잡도 O(N ** 3) def solution(A): N = len(A) prefix_sum = [A.copy() for _ in range(N)] min_val = 10 ** 10 answer = N for p in range(N): for q in range(p+1,N): if.. 2021. 3. 18.
Ansible 설치 및 SSH ProxyCommand 적용방법 ansible은 SSH기술을 이용하여 원격지 서버에 구성관리 할수 있도록 지원하는 도구이다. ansible과 SSH ProxyCommand 옵션을 이용하면, ssh 접속이 가능한 공인망과 내부망 자원에 대해 구성관리가 가능하다. 크게 두 단계로 요약이 가능하다 ansible이 ssh config 파일을 참조하도록 한다. ssh config 에 호스트 접속정보 (ip, user, port, private key, proxycommand) 를 정의한다. 1. Ansible 서버 생성 OS: CentOS 7.6 Spec: 1core X 2GB Public IP: 211.254.212.35 Port: 22 2. Ansible 설치 및 버전 확인 [root@kgh-ansible ~]# yum -y install .. 2021. 3. 17.
[Python] 5.2. GenomicRangeQuery app.codility.com/programmers/lessons/5-prefix_sums/ 5. Prefix Sums lesson - Learn to Code - Codility Compute number of integers divisible by k in range [a..b]. app.codility.com 1차 시도 Task Score 62% Correctness 100% Performance 0% 시간복잡도 O(N*M) def solution(S, P, Q): impact_factor = {"A":1,"C":2,"G":3,"T":4} lst = [] for K in range(len(P)): queries = set(S[P[K]:Q[K]+1]) min_val = 9 for q in querie.. 2021. 3. 16.
[Python] 5.1. CountDiv https://app.codility.com/programmers/lessons/5-prefix_sums/ 5. Prefix Sums lesson - Learn to Code - Codility Compute number of integers divisible by k in range [a..b]. app.codility.com Task Score: 100% Correctness: 100% Performance:100% 시간복잡도: O(1) def solution(A, B, K): answer = 0 if A == 0: answer += 1 if A 2021. 3. 15.
[Python] 순열 알고리즘 다음 순열 구하는 알고리즘 A[i-1] 0 and a[i-1] >= a[i]: i -= 1 # 더이상 다음 순열을 구할 수 없음 = False 리턴 if i = a[j]: j -= 1 # 3번 a[i-1], a[j] = a[j], a[i-1] # 4번 j = len(a)-1 while i < j: a[i], a[j] = a[j], a[i] i += 1 j -= 1 return True a = [2,3,1,7,6,5,4] next_perm(a) prin.. 2021. 3. 15.
[Python] 4.4. PermCheck https://app.codility.com/programmers/lessons/4-counting_elements/ 4. Counting Elements lesson - Learn to Code - Codility Calculate the values of counters after applying all alternating operations: increase counter by 1; set value of all counters to current maximum. app.codility.com Task Score 100% Correctness 100% Performance 100% 시간복잡도 O(N) or O(N * log(N)) def solution(A): _A = sorted(A) _B = .. 2021. 3. 15.
728x90
반응형