Skip to content

Instantly share code, notes, and snippets.

View rpf5573's full-sized avatar

YOONBYEONGIN rpf5573

View GitHub Profile
# -*- coding: utf-8 -*-
# from : https://programmers.co.kr/learn/courses/30/lessons/43163?language=python3
class Node:
def __init__(self, data):
self.visited = False
self.data = data
class Stack:
def __init__(self):
def solution(participant, completion):
hash_map = {}
length = len(completion)
for i in range(length):
c = completion[i]
if hash_map.get(c) == None:
hash_map[c] = 1
else:
hash_map[c] = hash_map[c] + 1
from collections import deque
q = deque()
def bfs(index, computers):
q.append(index)
while not (len(q) == 0):
i = q.popleft()
computers[i][i] = 0
for z in range(len(computers[i])):
@rpf5573
rpf5573 / catalan_number.py
Created February 14, 2019 07:57
catalan number
import math
def solution(n):
parent = math.factorial(2*n)
child = math.factorial(n) * math.factorial(n+1)
return parent / child
# -*- coding: utf-8 -*-
def get_brown(width, height) :
return 2*(width) + 2*(height+2)
def solution(brown, red):
carpet_width = 0
carpet_height = 0
elements = []
# -*- coding: utf-8 -*-
class Node :
val = 0
left = None
right = None
def __init__(self, val, left = None, right = None) :
self.val = val
self.left = left
# -*- coding: utf-8 -*-
class Node :
val = 0
left = None
right = None
def __init__(self, val, left = None, right = None) :
self.val = val
self.left = left
# -*- coding: utf-8 -*-
class Node :
val = 0
def __init__(self, val) :
self.val = val
leftNode = Node(100)
rightNode = Node(200)
d1 = [0, 1, 1, 1]
d2 = [1, 0, 1, 1]
dc = [2, 0, 2, 2]
def findCosineSimilarity(d1, d2) :
sum = 0.
d1_len = 0
d2_len = 0
for i in range(len(d1)) :
sum = (sum + d1[i] + d2[i])
@rpf5573
rpf5573 / insert_sort.py
Created January 27, 2019 07:45
insert sort in python
# -*- coding: utf-8 -*-
def swap(list, a, b) :
temp = list[b]
list[b] = list[a]
list[a] = temp
def insertSort(arr) :
for i in range(len(arr) - 1) :
if (arr[i] > arr[i+1]) :