hackerrank
-
[자료구조] [python] [Dynamic Programming] Sherlock and CostData miner/Algorithm & Data structure 2022. 2. 14. 13:24
Hackerrank의 Data structures 관한 문제 중에서 Medium에 속하는 문제이다. 원 문제 링크는 다음을 따라가보자. https://www.hackerrank.com/challenges/sherlock-and-cost/problem?isFullScreen=true - A Array의 앞에서부터 원소값을 결정한다고 하였을 때, A[i] - A[i-1]를 최대화 시키는 값을 가지는 A[i]의 경우의 수는 결국 A[i] =B[i] 이거나 A[i] = 1 이다. 이와 같은 성질을 이용하여, temp라는 임시 Array에 초기값이 (0, 0) 튜플을 원소로 가지는 배열을 만든다. 이 temp Array의 경우, 각 튜플의 첫번째 원소는 A[i]가 B[i]일 경우의 최대값을 저장하고, 두 번째 원..
-
[자료구조] [python] [BFS/DFS] Connected Cell in a GridData miner/Algorithm & Data structure 2021. 2. 24. 17:30
Hackerrank의 Data structures 관한 문제 중에서 Hard에 속하는 문제이다. 원 문제 링크는 다음을 따라가보자. www.hackerrank.com/challenges/ctci-connected-cell-in-a-grid/problem?h_r=internal-search DFS: Connected Cell in a Grid | HackerRank Find the largest connected region in a 2D Matrix. www.hackerrank.com 1) 방문한 점의 값이 1이라면, 방문한 점을 기준으로 거리 1에 해당하는 지점을 리턴하는 함수를 만든다. 단, 한 번이라도 방문하여 체크한 적이 있는지 확인하는 n *m 리스트를 따로 만든다(아래 코드에서 check 리스..
-
[자료구조] [python] Queries with Fixed Length (min-max)Data miner/Algorithm & Data structure 2021. 2. 7. 21:43
Hackerrank의 Data structures 관한 문제 중에서 Hard(success rate 60%)에 속하는 문제이다. 원 문제 링크는 다음을 따라가보자. www.hackerrank.com/domains/data-structures?filters%5Bstatus%5D%5B%5D=unsolved&filters%5Bstatus%5D%5B%5D=solved&filters%5Bsubdomains%5D%5B%5D=queues&badge_type=problem-solving Solve Programming Questions | HackerRank Join over 7 million developers in solving code challenges on HackerRank, one of the best w..
-
[자료구조] [python] Dynamic Array카테고리 없음 2021. 2. 1. 18:30
Hackerrank의 Data structures 관한 문제 중에서 Easy에 속하는 문제이다. 원 문제 링크는 다음을 따라가보자. www.hackerrank.com/challenges/dynamic-array/problem Dynamic Array | HackerRank Learn to use dynamic arrays by solving this problem. www.hackerrank.com Dynamic Array은 초기 설정된 자료의 크기에 국한되지 않고, 데이터를 이후에 추가할 수 있는 확장 가능한 자료형이다. XOR은, 두 값이 동일하면 0을, 두 값이 동일하지 않으면 1을 출력하는 논리 연산이다 문제 푸는 데 어려웠던 지점 1) 초반에 x,y가 무엇인지에 대해서 파악하는 부분에서 풀이 시..
-
[자료구조] [heap] 대기 시간 최소화Data miner/Algorithm & Data structure 2020. 3. 4. 21:02
Hackerrank의 Data structures 관한 문제 중에서 Hard에 속하는 문제이다. 원 문제 링크는 다음을 따라가보자. https://www.hackerrank.com/challenges/minimum-average-waiting-time/problem Minimum Average Waiting Time | HackerRank Calculate the minimum average wait time of a person to receive his/her pizza? www.hackerrank.com 문제는 다음과 같다. 피자 가게에서 고객들의 대기시간을 최소화하는 것을 목표로 평균 대기시간을 구하는 것이다. 피자 만드는 시간은 각기 다르며, 주문이 들어올 때, 선입선출(First in, Fir..
-
[자료구조] [heap] 업데이트 되는 array값의 중앙값 구하기Data miner/Algorithm & Data structure 2020. 3. 3. 17:33
Hackerrank의 Data structures 관한 문제 중에서 Hard에 속하는 문제이다. 원 문제 링크는 다음을 따라가보자. https://www.hackerrank.com/challenges/find-the-running-median/problem?h_r=internal-search Find the Running Median | HackerRank Find the median of the elements after inputting each element. www.hackerrank.com 연속적으로 주어지는 배열의 평균값들을 반복적으로 구하는 문제이다. [12,4,5,3,8,7]이 주어지면 앞에서부터 한 개씩 차례대로 추가하여 추가된 값들까지의 중앙값을 구하고, 이들이 포함된 리스트를 구하면 ..