본문 바로가기

프로그래밍

(27)
(Easy) 문자열에서 중복되는 문자 찾기 주어진 문자열에서 중복되는 문자를 찾는 알고리즘을 작성해보자. 중복되는 문자가 2개 이상이라면, 가장 빠른 문자가 정답이다.중복되는 문자가 없다면 -1 을 출력한다. 예제 입력ABBACDABCABXZZA 예제 출력A-1A 설명ABBAC -> A와 B가 중복된다. 하지만 A 가 가장 빠르게 나왔으니까 A 출력DABC -> 중복되는 문자없음. -1 출력ABXZZA -> A 만 중복된다. A 출력 답은 두가지 방법이 있다. 하나는 시간 복잡도가 O(n^2) 이고 다른 하나는 시간복잡도가 O(n) 이다. O(n^2)의 시간복잡도를 가진 코드를 먼저 작성해보자. loop를 문자열 전체로 돌린다. ( i = 0, ... n ) ABBAC 를 예로 들어보자.문자열의 가장 처음인 A 를 찾았다면 A 를 기준으로 ( i..
(Easy) Programming problem : Chandu and his Interns Chandu is a very strict mentor. He always gives a lot of work to his interns. So his interns decided to kill him. There is a party in the office on Saturday Night, and the interns decided to kill him on the same day. In the party, there are Nbeer bottles. Each bottle has a integer X written on it. Interns decided to mix poison in some of the beer bottles. They made a plan that they will add pois..
(Easy) Programming problem : ICPC Team Management. 모든 문제의 출처는 https://www.hackerearth.com 에 있다. 요즘 연습하는 정말 쉬운 프로그래밍 문제. Q. ICPC Team Management. Little Chandan is an exceptional manager - apart from his role in HackerEarth - as the person who has to bug everyone, in general... and if possible, try to get some work done.He's also offered a job as the coach of the best Russian teams participating for ACM-ICPC World Finals. Now, Chandan is an extre..