Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 오브젝트 풀링
- 백준 c++ 2468번
- 코테
- 백준 1103번 c++
- 17070번
- 2870번 c++
- 프로그래머스
- 백준 c++ 2870번
- 2870번 수학숙제
- Lv.3
- Lv2
- 백준 1103번
- Unity
- 백준 1103번 게임
- 2870번 수학숙제 c++
- 백준 17070번
- 플레이어 이동
- 백준
- 유니티
- 코딩테스트
- c++
- Algorithm
- 백준 17070번 c++
- C#
- dfs
- 2468 c++
- Beakjoon
- 2870번
- 수학숙제
- 백준 2870번
Archives
- Today
- Total
주녘공부일지
[프로그래머스 C#] Lv.2 타겟 넘버 본문
https://school.programmers.co.kr/learn/courses/30/lessons/43165
1. 정답코드 및 핵심 아이디어, 유의사항
- 배열 안의 부호를 변경할 수 있는 모든 경우의 수를 체크해야 함 // 배열은 참조형식 자료형
- DFS(Depth First Search) : 깊이우선탐색
https://godgjwnsgur7.tistory.com/47
using System;
public class Solution
{
public int count = 0;
public int solution(int[] numbers, int target)
{
Function(numbers, target, -1);
return count;
}
public void Function(int[] numbers, int target, int index)
{
index++;
if (numbers.Length == index)
{
int total = 0;
foreach (int num in numbers)
total += num;
if (total == target)
count++;
return;
}
Function(numbers, target, index);
numbers[index] *= -1;
Function(numbers, target, index);
}
}
'CodingTest > Programmers Lv.2' 카테고리의 다른 글
[프로그래머스 C#] Lv.2 뒤에 있는 큰 수 찾기 (0) | 2023.09.18 |
---|---|
[프로그래머스 C#] Lv.2 숫자 변환하기 (0) | 2023.09.07 |
[프로그래머스 C#] Lv.2 기능개발 (0) | 2023.09.03 |
[프로그래머스 C#] Lv.2 연속된 부분 수열의 합 (0) | 2023.08.30 |
[프로그래머스 C#] Lv.2 연속 부분 수열 합의 개수 (0) | 2023.08.25 |