Free Lines Arrow
본문 바로가기
728x90

전체 글353

[프로그래머스] 문자열 압축 문제 분석 압축한다.. 딱히 분석할게 없었다. 구현 #include #include #include using namespace std; int solution(string s){ int answer = 0; int findCount = 0; int index = 0; int minCount = 987654321; string findString=""; string compressString = ""; for(int i =1; i 1){ compressString += to_string(matchCount)+findString; } else { compressString += findString; } findString = tmpString; j-=findCount; matchCount = 0; } } .. 2021. 5. 15.
[프로그래머스] 올바른 괄호 문제 분석 벡터를 스택처럼 이용하여 푼다. 구현 #include #include #include using namespace std; bool solution(string s) { bool answer = true; // [실행] 버튼을 누르면 출력 값을 볼 수 있습니다. vector check; for(int i = 0; i < s.size(); i ++ ){ if( s.at(i) == '('){ check.push_back(s.at(i)); } else if (s.at(i) == ')') { if(check.empty()){ answer = false; break; } check.pop_back(); } } if( check.size() != 0 ){ answer = false; } return an.. 2021. 5. 15.
[프로그래머스] 삼각 달팽이 문제 분석 패턴을 찾기 처음에는 n 만큼 왼쪽 아래 대각선 방향으로 숫자를 채운다. 두번째는 n-1 만큼 아래를 채운다. 세번째는 n-2 만큼 왼쪽 위 대각선 방향으로 채운다. 처음부터 반복한다. 구현 #include #include #include using namespace std; int map[10001][10001]; int dirx[3] = {1, 0, -1}; int diry[3] = {0, 1, -1}; void solve(int n); vector solution(int n) { vector answer; solve(n); for(int i = 0; i < n; i++){ for(int j = 0; j 2021. 5. 15.
[Spring] 의존성 주입방법 1 의존성 주입 의존성 주입방법은 4가지가 있다. 생성자주입 수정자 주입 필드 주입 일반 메서드 주입 생성자 주입 생성자를 통해서 의존관계를 주입받는 방법. 특징 생성자 호출시점에 한번만 호출되는 것이 보장된다. 불편, 필수 의존관계에 사용된다. @Component public class OrderServiceImpl implements OrderService { private final MemberRepository memberRepository; private final DiscountPolicy discountPolicy; @Autowired // 생정자를 통한 주입방법 public OrderServiceImpl(MemberRepository memberRepository, DiscountPolicy .. 2021. 5. 15.
728x90
반응형