전체 글
-
-
-
-
-
프로그래머스 > 완전탐색 > 모의고사기타/알고리즘 2021. 9. 22. 21:33
수포자는 수학을 포기한 사람의 준말입니다. 수포자 삼인방은 모의고사에 수학 문제를 전부 찍으려 합니다. 수포자는 1번 문제부터 마지막 문제까지 다음과 같이 찍습니다. 1번 수포자가 찍는 방식: 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ... 2번 수포자가 찍는 방식: 2, 1, 2, 3, 2, 4, 2, 5, 2, 1, 2, 3, 2, 4, 2, 5, ... 3번 수포자가 찍는 방식: 3, 3, 1, 1, 2, 2, 4, 4, 5, 5, 3, 3, 1, 1, 2, 2, 4, 4, 5, 5, ... 1번 문제부터 마지막 문제까지의 정답이 순서대로 들은 배열 answers가 주어졌을 때, 가장 많은 문제를 맞힌 사람이 누구인지 배열에 담아 return 하도록 solution 함수를 작성해주세요...
-
-
싱글톤 패턴 *기타/디자인패턴 2021. 9. 14. 23:05
객체가 하나만 필요한 경우 스레드 풀, 캐시 대화상자, 사용자 설정, 레지스트리 설정 처리 객체, 로그 기록용 객체, 프린터나 그래픽카드 같은 디바이스를 위한 디바이스 드라이버 같은 객체 연결풀, 스레드풀 관리 전역변수의 단점 전역변수에 객체를 대입하면 애플리케이션이 시작될 때 객체가 생성되는데 (*플랫폼에 따라 다름) 근데 객체가 자원을 많이 차지한다면, 애플리케이션이 끝날 때까지 객체사용을 하지 않을 때 불필요하게 자원을 낭비하게 된다. 싱글톤 패턴은 필요할 때만 객체를 생성할 수 있다. * 어떻게 하면 한 클래스의 인스턴스가 두 개 이상 만들어지지 않도록 할 수 있을까? > new Obj(); new 생성자를 사용하지 못하게 한다. => 생성자를 private 으로 선언, 객체를 메서드를 통해 반환..
-