From 8ad1d8e136e21d31798cb924a3cb3827d880f48b Mon Sep 17 00:00:00 2001 From: LeePoongHo Date: Mon, 5 Oct 2020 21:29:37 +0900 Subject: [PATCH 1/2] TargetNumber --- LeePoongHo/README.md | 1 + LeePoongHo/TargetNumber.java | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 LeePoongHo/README.md create mode 100644 LeePoongHo/TargetNumber.java diff --git a/LeePoongHo/README.md b/LeePoongHo/README.md new file mode 100644 index 0000000..35a9521 --- /dev/null +++ b/LeePoongHo/README.md @@ -0,0 +1 @@ +# LeePoongHo 의 저장소 \ No newline at end of file diff --git a/LeePoongHo/TargetNumber.java b/LeePoongHo/TargetNumber.java new file mode 100644 index 0000000..bffa92f --- /dev/null +++ b/LeePoongHo/TargetNumber.java @@ -0,0 +1,25 @@ +class Solution { + public int solution(int[] numbers, int target) { + int answer = 0; + int index = 0; + int number = 0; + + return tcount(index, numbers, number, target); + } + + public int tcount(int index, int[] numbers, int number, int target) { + int length = numbers.length-1; + + if(index == length) { + if(number+numbers[index] == target) { + return 1; + } else if(number-numbers[index] == target) { + return 1; + } else { + return 0; + } + } else { + return tcount(index+1, numbers, number+numbers[index], target)+tcount(index+1, numbers, number-numbers[index], target); + } + } +} \ No newline at end of file From 7b736c758933e8a3cc81d589c6b67d8a38c6c0ac Mon Sep 17 00:00:00 2001 From: LeePoongHo Date: Sat, 31 Oct 2020 20:34:47 +0900 Subject: [PATCH 2/2] 2D Matrix --- LeePoongHo/2dMarix.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 LeePoongHo/2dMarix.java diff --git a/LeePoongHo/2dMarix.java b/LeePoongHo/2dMarix.java new file mode 100644 index 0000000..c5c522a --- /dev/null +++ b/LeePoongHo/2dMarix.java @@ -0,0 +1,12 @@ +class Solution { + public boolean searchMatrix(int[][] matrix, int target) { + for(int i=0; i