코딩테스트

    [BOJ/Java] 16652_Email Destruction  || Hashing

    [BOJ/Java] 16652_Email Destruction || Hashing

    16652번: Email DestructionIn the first example, the guess can be correct. For example, you could have emails with subjects “hello”, “Re: hello”, “Re: Re: hello”, “Re: Re: Re: hello”, “Re: Re: Re: Re: hello”, “world”, and “Re: world”. In the second examplwww.acmicpc.net문제 설명더보기You have an account on ICPCorrespondence.com. This is an email service where emails are grouped into chains by their subje..

    [Algorithm] 시간 복잡도 & 공간 복잡도

    ❕ 시간 복잡도입력에 대해 총 얼마나 오래 걸리는 지를 의미한다. 알고리즘이 진행되면서 연산되는 횟수이다. 빅오 표기법을 사용하여 표현하는데, 빠르게 증가하는 항만 고려하여 표기한다.arr = [1, 2, 3, 4, 5] sum = 0 for i in arr: sum += i print(sum)N개의 입력을 받고 연산 횟수는 N에 비례하기 때문에, 시간 복잡도는 $O(N)$이다. a = 5 b = 7 print(a + b)한 번의 연산만 하기 때문에 시간 복잡도는 $O(1)$이다 arr = [3, 5, 1, 2, 4] for i in arr: for j in arr: print(i + j)N개의 입력을 받고 N X N만큼의 연산이 필요하기 때문에 시간 복잡도는 $O(N^2)$이다. $O(1)$