hyez / algorithms Goto Github PK
View Code? Open in Web Editor NEW알고리즘 및 코딩테스트 공부
알고리즘 및 코딩테스트 공부
문자열로 된 시간을 '초'단위로 바꾸기
HH:MM:SS => 초로 바꾸기
def str_to_int(time):
h, m, s = time.split(':')
return int(h) * 3600 + int(m) * 60 + int(s)
def int_to_str(time):
h = time // 3600
h = '0' + str(h) if h < 10 else str(h)
time = time % 3600
m = time // 60
m = '0' + str(m) if m < 10 else str(m)
time = time % 60
s = '0' + str(time) if time < 10 else str(time)
return h + ':' + m + ':' + s
PyPy3는 기본적으로 Python3와 동일한 문법을 지원하지만
코어적으로 더욱 빠르게 동작한다는 이유로 PyPy3의 사용을 추천하는데,
메모리 사용량이 파이썬3보다 많다는 점을 고려하여 푸는 문제의 종류에 따라 잘 선택해야함
시간 효율성 => PyPy3이 좋음
메모리 효율성 => Python3이 좋음
from math import gcd # 최대공약수
def lcm(x, y):
return x * y // gcd(x, y)
import sys
input = sys.stdin.readline
시간 효율성을 요구하는 문제에서는 반드시 위의 코드를 써줘야 정상작동함 (훨씬 빠르게 작동)
재귀함수 사용시 런타임 에러 -> 다음 코드로 해결
import sys
sys.setrecursionlimit(10**6)
음수 가중치가 있다면?! => 다익스트라가 아닌 벨만포드를 사용하자..
단! Complexity는 주의! => O(EV)이므로 노드, 간선 개수가 작을때 사용
이 때, INF 변수를 int가 아닌 아래처럼 사용해야 distance 존재 여부 등 판단 시 스무스하게 해결됨
INF = float('inf') # 이렇게 사용해야함
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.