Problem Solving83 [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. [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] 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. [Python] 4.3. MissingInteger 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 정답률: 100% (Task Score 100%, Correctness 100%, Performance 100%) 시간복잡도: O(N) or O(N * log(N)) def solution(A): _A = .. 2021. 3. 15. [Python] 4.2. MaxCounters 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 정답률: 88% 시간복잡도:O(N + M) def solution(N, A): cnt = [0] * N maxcnt = 0 for K in range(len(A)): if A[K]-1 < N: cnt[A[K.. 2021. 3. 14. 이전 1 2 3 4 5 6 7 ··· 10 다음 728x90 반응형