일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 자바 공부
- websocket
- 디자인 패턴
- 프로그래머스
- vanillaJS
- 백준
- 자바스크립트
- 프로그래머스 자바
- 장고
- react hook
- 컴퓨터 네트워크
- 코딩테스트 고득점 Kit
- design pattern
- 코틀린
- 프로그래머스 완전탐색
- 리액트 훅
- React JS
- useEffect
- 리액트
- NextJS
- 코딩테스트 고득점 Kit 완전탐색
- react firebase
- JavaScript
- 데이터모델링과마이닝
- 프로그래밍 언어론
- react
- useState
- codesandbox
- 자바
- Java
Archives
- Today
- Total
목록타겟 넘버 dfs 자바 java (1)
기록하는 개발자

class Solution { static int answer; /* index : 몇 번째 인덱스인지, sum : index까지 총 더한 값 */ public void dfs(int[] numbers,int target,int index,int sum){ /* numbers 배열을 끝까지 탐색한 경우 */ if(index == numbers.length){ if(sum == target) // 총합이 target과 같다면 answer++; // 정답 개수 1 증가 return; } /*배열 탐색 -1) 다음 인덱스(index+1)에서 양수인 numbers[index]를 그대로 더하기 -2) 다음 인덱스(index+1)에서 음수인 numbers[index]를 더하기 */ else { dfs(numbers..
Algorithm
2021. 6. 11. 22:24