검색결과 리스트
글
codility Lesson 풀어보기 4
Codiliy Lesson 풀어보기 Day4.
- 아직은 Easy 위주로 진행.
- MVC 스프링 2편 완강 후 코딩테스트 진행
Codility Lesson 4. Counting Elements - PermCheck
- 연달아 숫자가 존재하는지 체크
https://app.codility.com/demo/results/trainingERT3BQ-RR8/
Test results - Codility
A non-empty array A consisting of N integers is given. A permutation is a sequence containing each element from 1 to N once, and only once. For example, array A such that: A[0] = 4 A[1] = 1 A[2] = 3 A[3] = 2 is a permutation, but array A such that: A[0] =
app.codility.com
Codility Lesson 5. Prefix Sums - PassingCars
- 0 ≤ P < Q < N
- 뒤에서부터 계산 시 현재까지 계산된 Q의 계산값 + 새로 서쪽으로 판단되는 값을 더하면 된다는 것을 생각하자.
https://app.codility.com/demo/results/trainingYT6WAG-223/
Test results - Codility
A non-empty array A consisting of N integers is given. The consecutive elements of array A represent consecutive cars on a road. Array A contains only 0s and/or 1s: 0 represents a car traveling east, 1 represents a car traveling west. The goal is to count
app.codility.com
Codility Lesson 6. Sorting - Distinct
ArrayList result = new ArrayList<>();
for(int i=0; i<A.length; i++)
if(!result.contains(A[i])){
result.add(A[i]);
}
return result.size();
- Distinct 배열을 만들 시 N이 클 때 퍼포먼스를 통과하지 못함 75%
- 중복 값만 제외하는 형태로 로직 다시 짜야함
https://app.codility.com/demo/results/trainingHGSF83-423/
Test results - Codility
Write a function class Solution { public int solution(int[] A); } that, given an array A consisting of N integers, returns the number of distinct values in array A. For example, given array A consisting of six elements such that: A[0] = 2 A[1] = 1 A[2] = 1
app.codility.com
- 중복값만 계산해서 A.length - 중복 갯수로 로직 구현하여 퍼포먼스도 통과
Codility Lesson 6. Sorting - MaxProductOfThree
- 3개의 숫자를 곱해야하므로 가장 큰 값은 항상 들어가야하며, 가장 작은 음수 숫자 2개의 곱셈결과와 두번째, 세번째로 큰 값의 곱셈결과 중 큰 값을 구하면 되는 문제
- 다만 모든 값이 음수인 경우 가장 작은 값 3개의 결과값이 필요함.
https://app.codility.com/demo/results/training6UJ42N-V4Y/
Test results - Codility
A non-empty array A consisting of N integers is given. The product of triplet (P, Q, R) equates to A[P] * A[Q] * A[R] (0 ≤ P < Q < R < N). For example, array A such that: A[0] = -3 A[1] = 1 A[2] = 2 A[3] = -2 A[4] = 5 A[5] = 6 contains the following exam
app.codility.com
Codility Lesson 6. Sorting - Triangle
- triplet (P, Q, R)에 대해 A[P] + A[Q] > A[R] 조건을 만족하는 원소가 있는지만 찾으면 됨
- MAX_INT Overflow 에 걸렸는데 (long)으로 캐스팅해서 패스함
https://app.codility.com/demo/results/training9ET7YY-UQM/
Test results - Codility
An array A consisting of N integers is given. A triplet (P, Q, R) is triangular if 0 ≤ P < Q < R < N and: A[P] + A[Q] > 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
Codility Lesson 7. Stacks and Queues - Brackets
- Stack을 사용해서 구현
https://app.codility.com/demo/results/trainingJZAKU4-CPK/
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
Codility Lesson 7. Stacks and Queues - Fish
- Stack을 사용해서 구현. 하류로 가는 물고기들의 인덱스를 stack에 저장 및 비교
https://app.codility.com/demo/results/training2C3RV4-E2U/
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
'Coding Test 준비 > codility' 카테고리의 다른 글
codility Lesson 풀어보기 6 (0) | 2022.08.20 |
---|---|
codility Lesson 풀어보기 5 (0) | 2022.08.15 |
codility Lesson 풀어보기 3 (0) | 2022.06.29 |
codility Lesson 풀어보기 2 (0) | 2022.06.26 |
codility Lesson 풀어보기 (0) | 2022.06.19 |