Leetcode[1]⭐ - 1025. Divisor Game, 1221. Split a String in Balanced Strings, 104. Maximum Depth of Binary Tree

1025. Divisor Game 1025. Divisor Game Keyword: Dynamic Programming Base Factor: n이 2일 때, True. n이 3일 때, False. ==> 2를 넘겨 받은 사람이 Win. 3을 넘겨 받은 사람은 Loose...

Data-Structure[0] - Priority Queue와 Heap

Priority Queue(우선순위 큐) Priority queue Queue와 비슷하지만 각각의 요소가 “priority”를 가지고 있다. Abstact Data Type이다. Methods Priorty ADT는 다음의 Method를 지원한다. P.add(k,v): priority가 k고 값이 v인 요소를 insert한다. P.min(): k가...

Alogrithm[6]:⭐⭐ - Greedy Method(Coin Change Problem, Fractional Kanpsack Problem)

Greedy Method(또는 Greedy Algorithm) Greedy algorithm A greedy algorithm is any algorithm that follows the problem-solving heuristic of making the locally optimal choice at each stage. 탐욕 알고리즘은 최적해를 계산할...

Alogrithm[5]:⭐⭐ - Graph Traversals(DFS and BFS)

Graph Traversal(그래프 순회) 그래프의 모든 vertices와 edges(또는 nodes와 branches)를 검사함으로써 그래프를 탐색하는 과정 또는 절차. 대표적인 알고리즘으로 DFS(깊이우선탐색)와 BFS(너비우선탐색)가 있다. Graph Traversal의 활용 그래프의 Reachablity에 대한 문제에 활용. u에서 v로가는...

Leetcode[0]:⭐ - 704. Binary Search

704. Binary Search Pointers 문제를 해결하기 위해서는 세 가지 인덱스 변수가 필요하다. left: 왼쪽 경계를 나타내는 인덱스 변수. Inclusive right: 오른쪽 경계를 나타내는 인덱스 변수. Inclusive mid: target과 비교대상이 되는...

Alogrithm[4]:⭐ - Linear Search, Binary Search

Searching Algorithm(검색 알고리즘) Sequence안에 특정 target value가 있는지 없는지 알기 위한 검색 알고리즘. search: if target in data: return True else: return False Unsorted, Sorted 어떤 검색 알고리즘을 사용할 것인지...

Alogrithm[3]:⭐ - Merge Sort, Quick Sort.

Divide and Conquer One of an algorithmic design pattern that use recursion 세 가지 단계로 이루어져 있다. Divide: input size를 한 개 이상의 기준에 따라 나눈다.(Ex. 한 개의 Set를 두...

Alogrithm[2]:⭐ - Bubble Sort, Selection Sort

Bubble sort List가 주어여졌을 때, 왼쪽에 있는 숫자가 오른쪽에 있는 숫자보다 크다면 swap이 일어난다. # swap if a > b: a, b = b, a # test nums = [4,2,3,1]...

Alogrithm[1]:⭐ - Single Number

Q. Leetcode: 136. Single Number 방법 1. dictionary 자료형 이용 리스트를 순회하여 key는 num, value는 count를 가지는 dictionary를 만든다. dictionary를 순회하여 value가 1인 key값을 찾아 반환한다. dict.get() class Solution: def...

Alogrithm[0]:⭐⭐

Q. Leetcode: 430. Flatten a Multilevel Doubly Linked List (Doubly) Linked List and Stack Linked List는 head 노드를 통해서 List의 데이터에 접근한다. Doubly Linked List는 prev 를 통해서 이전 노드에도...