본문 바로가기

전체 글132

[Codility] Dominator (JavaScript) https://app.codility.com/programmers/lessons/8-leader/dominator/ Dominator coding task - Learn to Code - CodilityFind an index of an array such that its value occurs at more than half of indices in the array.app.codility.com 문제:주어진 배열 중 절반 이상 등장한 원소가 있다면, 해당 원소의 인덱스를 반환. 없다면 -1 반환.내 풀이:/** * 배열 A의 원소 중 개수가 절반 이상인 원소, 즉 지배 원소가 존재하는지 검증 * * @params {number[]} A - 배열 A * @returns {number} 리더 원소 존재.. 2025. 6. 14.
[Codility] Fishes (JavaScript) https://app.codility.com/programmers/lessons/7-stacks_and_queues/fish/ Fish coding task - Learn to Code - CodilityN voracious fish are moving along a river. Calculate how many fish are alive.app.codility.com 문제:살아남은 물고기의 수를 계산 및 반환한다. 각 물고기는 이동 방향과 크기가 있다. 반대방향의 물고기를 만났을 때, 상향하는 물고기가 더 크다면 먹는다.내 풀이:/** * 살아남은 물고기의 수를 계산 및 반환하는 함수 * * 각 물고기는 이동 방향과 크기가 있다. * 반대방향의 물고기를 만났을 때, 상향하는 물고기가 더 크다면 먹는다.. 2025. 6. 14.
[Codility] Brackets (JavaScript) https://app.codility.com/programmers/lessons/7-stacks_and_queues/brackets/ Brackets coding task - Learn to Code - CodilityDetermine whether a given string of parentheses (multiple types) is properly nested.app.codility.com 문제:주어진 중첩괄호 문자열이 쌍을 이루고 있다면 1, 아니면 0 반환한다. 문자열이 비어있어도 1 반환한다.내 풀이:function solution(S) { if (S.length === 0) return 1; const stack = []; const arr = [...S]; fo.. 2025. 6. 14.
[Codility] GenomicRangeQuery (JavaScript) https://app.codility.com/programmers/lessons/5-prefix_sums/genomic_range_query/ GenomicRangeQuery coding task - Learn to Code - CodilityFind the minimal nucleotide from a range of sequence DNA.app.codility.com 문제:유전자 문자열 S와 범위를 정할 배열 P, Q 2개를 받는다. P[i]를 시작 인덱스, Q[i]를 끝 인덱스로 둔다. 문자열 S에서 P[i]~Q[i]에 있는 유전자 중 맵핑된 가장 작은 숫자값을 찾아리턴한다. (S를 이루는 A, C, G, T 는 각각 1, 2, 3, 4로 맵핑되어 있다.)내 풀이:function solution(.. 2025. 6. 14.
[Codility] Count Divs (JavaScript) https://app.codility.com/programmers/lessons/5-prefix_sums/count_div/ CountDiv coding task - Learn to Code - CodilityCompute number of integers divisible by k in range [a..b].app.codility.com 문제:A부터 B 사이의 수 중 i로 K를 나누었을 때, 0인 숫자의 개수를 반환한다.내 풀이:function solution(A, B, K) { let count = 0; for (let i = A; i - 채점결과: 50%분석:정확도는 성공, 효율성에서 큰 수가 들어올 경우 모두 타임아웃 에러 발생Performance tests▶ big_valuesA =.. 2025. 6. 14.
[Codility] Passing Cars (JavaScript) https://app.codility.com/programmers/lessons/5-prefix_sums/passing_cars/ PassingCars coding task - Learn to Code - CodilityCount the number of passing cars on the road.app.codility.com 문제:도로에 겹치는 차량 쌍 개수를 반환한다.내 풀이:function solution(A) { let eastCnt = 0; let pairs = 0; for (const a of A) { if (a === 0) { eastCnt++; } else { pairs += eastCnt; } .. 2025. 6. 14.
[Codility] MaxCounters (JavaScript) https://app.codility.com/programmers/lessons/4-counting_elements/max_counters/ MaxCounters coding task - Learn to Code - CodilityCalculate the values of counters after applying all alternating operations: increase counter by 1; set value of all counters to current maximum.app.codility.com문제 요구사항:N 길이인 배열에 조건에 따라 결과를 담아서 반환한다.배열의 A[K]번째 위치에조건 1. 주어진 A 배열의 A[K]가 N보다 작거나 같다면 결과 + 1을 하고,N + 1과 같다면 모.. 2025. 6. 14.
[Codility] PermCheck (JavaScript) https://app.codility.com/programmers/lessons/4-counting_elements/perm_check/ PermCheck coding task - Learn to Code - CodilityCheck whether array A is a permutation.app.codility.com 문제 요구사항: 배열이 순열이라면 1, 아니라면 0을 리턴한다. 내 풀이: function solution(A) { let result = 1; A.sort(); // 정렬 for (let i = 0; i - 채점 결과: 75% 분석: Correctness tests: - permutations_of_ranges: permutations of sets like [2.... 2025. 6. 14.
[Essay] 깃 컨벤션 작성 방법 💻 깃 컨벤션이란 깃 컨벤션은 팀 내에서 일관된 커밋 메시지 작성 규칙을 정하는 것이다. 이를 통해 프로젝트 관리와 협업을 효율적으로 할 수 있어서, 혼자 사이드를 할 때나, 팀 단위로 프로젝트를 관리할 때도 매우 좋은 습관이어서 기록 겸 공유하고자 한다. 🤷‍♀️ 커밋 메시지 규칙이 없다면? 깃 컨벤션이 왜 필요한가? 초보 개발자이거나, 혼자 개발하는 데에 익숙한 사람이라면 아직 필요성을 못 느낄 수 있다. 그렇다면 만약의 상황을 가정해 보겠다. 프로젝트를 진행하는 중간에 버그 히스토리를 파악하고 싶거나, 복잡한 브랜치들 사이에서 특정 커밋을 찾아 머지를 하고 싶은 상황이 생긴다. 이때, 커밋들이 모두 '수정', '수정2', '최종수정' 이런 식으로 작성되어 있다면 어떻게 하겠는가? 내가 모든 변경사항.. 2024. 4. 21.