티스토리 뷰

반응형

topcoder SRM494 Div2 Level1 interesting party

원 문제 주소 (로그인하고 하고 난뒤에 보임... 그냥 interesting party 로 검색하는게 더빠름)

https://arena.topcoder.com/index.html#/u/practiceCode/14480/15196/11312/2/307028




공통된 단어를 찾는것이다.

brute force 방식으로 전체탐색하면된다.

n^2의 시간복잡도로 수행할 수 있다.

n이 50까지였기에 망정이지만, 100만인경우 O(n)의 접근법으로 구현해야한다.

그럴땐 맵 또는 딕셔너리 자료구조를 이용하면된다.


C/C++ 소스보기

https://github.com/ingyeoking13/algorithm/blob/master/topcoder/interestingparty.cc


반응형

'알고리즘 문제 > Brute Force' 카테고리의 다른 글

백준 1748 수 이어 쓰기 1  (0) 2018.01.26
863B : Kayaking  (0) 2017.11.05
완전탐색(Brute Force) 문제집  (0) 2017.10.23