data_structure
-
[자료구조] [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] Castle on the Grid (deque)Data miner/Algorithm & Data structure 2021. 2. 3. 18:30
Hackerrank의 Data structures 관한 문제 중에서 Medium에 속하는 문제이다. 원 문제 링크는 다음을 따라가보자. www.hackerrank.com/challenges/castle-on-the-grid/problem Castle on the Grid | HackerRank Determine the number of steps to move a castle to the goal position on a given grid. www.hackerrank.com Deque는 python의 collection 모듈에 구현된 객체/자료형이다. stack과 que의 일반형태의 자료형이며, Deque는 thread-safe (스레드 안전)을 지원하며, 자료의 양방향에서 O(1) 성능으로 원소를 추..
-
[자료구조] [python] Balanced Brackets (stack)Data miner/Algorithm & Data structure 2021. 2. 2. 18:30
Hackerrank의 Data structures 관한 문제 중에서 Medium에 속하는 문제이다. 원 문제 링크는 다음을 따라가보자. www.hackerrank.com/challenges/balanced-brackets/problem Balanced Brackets | HackerRank Given a string containing three types of brackets, determine if it is balanced. www.hackerrank.com Stack의 개념과 가장 맞닿아 있는 문제이다. 빈출되었던 문제이기도 하다. 문제를 풀이하는데 있어서 어려웠던 점은 다음과 같다. 괄호의 순서가 '균형되어'(Balanced) 있다면, '{[()]}' 완전히 양쪽의 대괄호가 균형된 예시만을 처리..