개발 여정/코딩테스트 준비
-
다익스트라 알고리즘 (Dijkstra's Algorithm)개발 여정/코딩테스트 준비 2023. 2. 26. 13:31
다익스트라 알고리즘 (Dijkstra's Algorithm) | 그래프의 두 정점 사이에 존재하는 최단 경로를 찾는 것 쓰이는 곳 GPS: 최단 경로 찾기 네트워크 라우팅: data path 최단 경로 찾기 Biology: 바이러스의 확산 경로 항공 티켓: 가장 저렴한 루트 찾기 ...etc class WeightedGraph{ constructor(){ this.adjacencyList = {}; } addVertex(vertex){ if(!this.adjacencyList[vertex]) this.adjacencyList[vertex] = []; } addEdge(vertex1, vertex2){ // 가중 그래프이기 때문에 키값에 객체 형식으로 node, weight을 추가해줌 this.adjace..
-
HackerRank 1달 과정 1주차 11번- Subarray Division 1개발 여정/코딩테스트 준비 2022. 1. 19. 23:31
https://www.hackerrank.com/challenges/one-month-preparation-kit-the-birthday-bar/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=preparation-kits&playlist_slugs%5B%5D=one-month-preparation-kit&playlist_slugs%5B%5D=one-month-week-one Subarray Division 1 | HackerRank Given an array of integers, find the number of subarrays of length k having sum s. www.hackerrank.com 문제 릴리와 론이 초코렛 바를 ..
-
HackerRank 1달 과정 1주차 10번- Permuting Two Arrays개발 여정/코딩테스트 준비 2021. 12. 28. 00:52
https://www.hackerrank.com/challenges/one-month-preparation-kit-two-arrays/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=preparation-kits&playlist_slugs%5B%5D=one-month-preparation-kit&playlist_slugs%5B%5D=one-month-week-one n개의 길이를 가진 배열 A와 B가 있고, 이를 재정렬했을 때 A[i] + B[i]의 값이 n보다 크거나 같을 경우 "YES", 아닐 경우 "No"를 return하는 문제이다. 사실 HackerRank는 문제 자체만 봤을 때 잘 이해가 안 가는 경우가 많다. 밑에 샘플 설명을 봐야 ..
-
HackerRank 1달 과정 1주차 9번- Pangrams개발 여정/코딩테스트 준비 2021. 12. 25. 23:17
https://www.hackerrank.com/challenges/one-month-preparation-kit-pangrams/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=preparation-kits&playlist_slugs%5B%5D=one-month-preparation-kit&playlist_slugs%5B%5D=one-month-week-one pangram은 모든 알파벳을 포함한 문자열을 말한다. 주어진 문자열이 pangram이 맞는지 아닌지 판별하는 문제이다. Logic: 중복을 허용하지 않는 set의 성질을 이용하여, 거기에 주어진 문자열들의 알파벳들을 넣고 실제 알파벳 개수인 26개와 맞는지 확인한다. class Sol..
-
HackerRank 1달 과정 1주차 8번- Counting Sort 1개발 여정/코딩테스트 준비 2021. 12. 24. 22:28
https://www.hackerrank.com/challenges/one-month-preparation-kit-countingsort1/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=preparation-kits&playlist_slugs%5B%5D=one-month-preparation-kit&playlist_slugs%5B%5D=one-month-week-one List arr가 주어지면 arr 안의 정수가 result 배열의 인덱스가 되어, arr 정수가 얼마나 나타는지 빈도수를 count하는 문제이다. class Result { /* * Complete the 'countingSort' function below. * * The f..
-
HackerRank 1달 과정 1주차 7번- Diagonal Difference개발 여정/코딩테스트 준비 2021. 12. 21. 19:13
https://www.hackerrank.com/challenges/one-month-preparation-kit-diagonal-difference/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=preparation-kits&playlist_slugs%5B%5D=one-month-preparation-kit&playlist_slugs%5B%5D=one-month-week-one 정사각 매트릭스 형태로 구성된 int들이 주어지면 이를 각 대각선 순서로 더한다. 왼쪽 오른쪽 합을 따로 구한 뒤, 두 합의 차를 구해야 한다. (음수이면 양수로 전환) class Result { public static int diagonalDifference(Li..
-
HackerRank 1달 과정 1주차 6번- Flipping bits개발 여정/코딩테스트 준비 2021. 12. 21. 00:24
https://www.hackerrank.com/challenges/one-month-preparation-kit-flipping-bits/problem?filter=java&filter_on=language&h_l=interview&isFullScreen=true&page=1&playlist_slugs%5B%5D=preparation-kits&playlist_slugs%5B%5D=one-month-preparation-kit&playlist_slugs%5B%5D=one-month-week-one 문제 32bit의 10진수가 주어지면 이를 2진수로 바꾸고, 2진수에서 0과 1을 바꾸어 다시 10진수로 바꾼다. 요약하면 10진수 -> 2진수 1 0 2진수 -> 10진수 class Result { /* * ..
-
HackerRank 1달 과정 1주차 5번 - Lonely Integer개발 여정/코딩테스트 준비 2021. 12. 19. 21:55
https://www.hackerrank.com/challenges/one-month-preparation-kit-lonely-integer/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=preparation-kits&playlist_slugs%5B%5D=one-month-preparation-kit&playlist_slugs%5B%5D=one-month-week-one 주어진 int 배열 a에서 중복되지 않는 배열요소를 가져오는 문제 HashMap을 만들어 key값은 a의 요소, value값은 중복회수로 하기로 했다. 그 후 HashMap의 value가 0이면 그 key를 반환하기로 함. class Result { public static ..