분류 전체보기(14)
-
Leetcode - 70. Climbing Stairs
You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 처음에는 수학문제처럼 느껴졌었는데 n 칸의 계단을 1 이나 2 만큼씩 올라갈수 있을때 몇가지 방법 이있냐는 문제였다. 일단 dp 라는걸 모른다는 가정하에 (dp 문제 였지만 ;;) 노가다로 패턴을 찾기 시작했다. n =1 ways = 1 n =2 ways = 2 n = 3 ways = 3 n = 4 ways = 5 n = 5 ways = 8 너무 힘들어서 더는 못하겠다 ㅠㅠ 잉? 근데 뭔가 느낌이 피보나치 인거 같아서 ..
2023.10.13 -
217. Contains Duplicate
하나씩 돌며 모두 확인하면 O(n^2) sorting 하면 중복되는 데이터가 바로 옆으로 정렬되기 때문 O(n logn) hashset 에 데이터를 하나씩 넣고 반복이 생기면 return true O(n) class Solution(object): def containsDuplicate(self, nums): num_set = set() for i in nums: if i in num_set: return True else: num_set.add(i) return False set 을 만들어주고 nums 를 순회하며 이미 set 에 있으면 true 를 return, 없으면 setr 에 추가한다. 다 돌고 없으면 false 리턴
2023.09.25 -
Introduction to Dijkstra's Algorithm
최소한으로 방문, 마지막까지 닿으면 끝남
2023.07.23 -
Module 13 - Introduction to Graph Algorithms
graph 란? linked list , binary tree 도 전부 그래프이다 Order = vertex 의 개수 그림에선 5개 Size = edge 개수, 그림에서 6개 Degree = 그 vertex 로 이어지는 edge 의 개수 A = 3 두 점끼리 방향 없이 이어짐 = path path 가 vertex 를 반복하지 않으면 simple path 라고 부름 Dense = 그래프가 거의 maximum edges 일때 Sparse = 그래프가 거의 minimum edges 일때 그래프가 self loop 이나 같은곳으로 가는게 두개 이상이면 NON- simple graph 그렇지 않으면 simple graph 이다 Depth-First Search (DFS) Introduction We have to..
2023.07.23 -
module 11- Pattern Matching
brute force - bubble sort Boyer moore kmp - complicated rabin-karp - radix sort , integer manipulation
2023.07.11 -
Module 11 - Divide & Conquer Sorts
solving large problem by breaking into small parts MERGE SORT QUICKSORT pivot 을 앞으로 빼고 왼 오 끝을 i j 로 설정 pivot 보다 큰 i 를 찾고 pivot 보다 작은 j 를 찾으며 가운데로 모임 찾으면 swap 다 하면 j 랑 pivot 이랑 swap LSD RADIX SORT 이걸 계속 반복 QUICK SELECT
2023.07.10