#1 2SUM #2 No Division Multiplying
2020. 8. 7. 15:19ㆍPS/도전
All problems are from https://www.dailycodingproblem.com/
Solution Codes : https://github.com/Kusin/DailyCoding
#1
Approach 1 : Sort and Bianry search O(N log N)
sort arr
for k in arr -> find (Goal-k) in arr by binary sort
Approach 2 : Use Hash, O(N)
for k in arr -> hash k
for k in arr -> find (Goal-k) in arr by Hash
#2
Approach 1 : O(N^2) , calculate every product
Better Approach : Use Prefix, Suffix Array. O(N) Preprocess, and calculate by O(N)
728x90
'PS > 도전' 카테고리의 다른 글
Problem #4 : First missing positive integer (0) | 2020.08.15 |
---|---|
#3 Parse & ReverseParse a Binary Tree (0) | 2020.08.15 |
KOI 2019 2차 대회 2번 '괄호' 풀이 (0) | 2020.07.11 |
한국정보올림피아드(KOI) 공부 시작하기 (9) | 2020.05.01 |
[도전 30일차] 다각형의 확장 (도전중) (0) | 2020.04.30 |