Q: 시간복잡도와 공간복잡도가 무엇인지 설명해주실 수 있을까요?
A:
Q: 포트폴리오에서 시간복잡도를 낮춘 사례가 있다면 설명해주실 수 있을까요?
A:
for문으로 200개가 넘는 시군구 리스트를 다 돌지 않게 시도별(17개) 시군구(1~32개) 리스트를 따로 만들어서 여행 장소의 시군구를 찾을 때 for문 반복 횟수를 줄였습니다.
* 포트폴리오 말고 프로그래머스 코딩테스트 연습 달리기 경주. Lv.1. 40%
- index()(O(n))와 [](O(1))
for i in callings:
call_index = players.index(i)
: O(n x m) n: callings. for loop, m: players. index()
players_dictionary = {string: i for i, string in enumerate(players)}
for i in callings:
call_index = players_dictionary[i]
: O(n)
https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=junhyuk7272&logNo=221247061276
nx(a+l)/2
'TIL' 카테고리의 다른 글
TIL 081623 (0) | 2023.08.16 |
---|---|
TIL 081423 (0) | 2023.08.14 |
TIL 081023 (0) | 2023.08.10 |
TIL 080923 (0) | 2023.08.09 |
TIL 080823 (0) | 2023.08.08 |