Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5c689c6
Be2020 (#84)
honux77 Feb 3, 2020
c74bfc2
Test Commit
102092 Feb 3, 2020
71ce751
TestCommit 삭제, 프로그래머스 Top 문제 해결
102092 Feb 4, 2020
fb68346
Revert "TestCommit 삭제, 프로그래머스 Top 문제 해결"
102092 Feb 4, 2020
e23f568
브랜치 수정, Top commit
102092 Feb 4, 2020
97c76bd
Merge branch 'be2020' of https://github.com/102092/nodejs-algorithm i…
102092 Feb 4, 2020
eee2675
Programmers 모의고사
102092 Feb 5, 2020
4d9f4d9
Test Commit
102092 Feb 3, 2020
4cbf47d
브랜치 수정, Top commit
102092 Feb 4, 2020
f081367
Merge branch 'be2020' of https://github.com/102092/nodejs-algorithm i…
102092 Feb 8, 2020
966643f
프로그래머스 체육복, sql (GroupBy1)
102092 Feb 11, 2020
dc560b5
0212, 0213 Leet + Programmers , sql
102092 Feb 13, 2020
2ec3042
IsNull, ValidParentheess
102092 Feb 14, 2020
6cb8bea
Leetcode : MergeSortedList, Programmers : IsNull
102092 Feb 17, 2020
34a9ef8
LeetCode : MergeSortedArray, SQL : IsNull3
102092 Feb 18, 2020
a932d11
프로그래머스 : 라면공장, Join1
102092 Feb 19, 2020
6cf36e5
0220 : Leetcode, SQl , Programmers;
102092 Feb 20, 2020
35690e8
0221 : sql 1, easy-2
102092 Feb 21, 2020
a606c49
0224 : join4, leetcode easy 1, programmers level2 1
102092 Feb 24, 2020
05863bd
0225 : sql1, leetcode1, programmer1
102092 Feb 25, 2020
d4ecda0
0226 : programmers, sql1
102092 Feb 27, 2020
122f04f
0227 : leetcode 1, programmer sql1
102092 Feb 27, 2020
3d0f41c
0228 : leetcode1, sql1
102092 Feb 28, 2020
af4b9ac
0301 : 프로그래머스 lv1 2문제, sql 1문제
102092 Mar 1, 2020
69d4a35
0302 : leetcode 3
102092 Mar 2, 2020
a14eb40
0304 : Leetcode 2, programmers 1
102092 Mar 4, 2020
8847763
0305 : 2문제
102092 Mar 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions 200211/102092/groupby1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
https://programmers.co.kr/learn/courses/30/lessons/59040
*/

SELECT ANIMAL_TYPE,COUNT(ANIMAL_TYPE) FROM ANIMAL_INS GROUP BY ANIMAL_TYPE ORDER BY ANIMAL_TYPE;
85 changes: 85 additions & 0 deletions 200211/102092/workoutClothes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

/*
https://programmers.co.kr/learn/courses/30/lessons/42862

1. Greedy 문제
2. 다중 for문을 돌려야하나?
3. 정확히 어떤 컨셉의 문제인지 빠르게 캐치가 안됨.
4.
*/

class Solution {

public int solution(int n, int[] lost, int[] reserve) {
int result = n;
result -= lost.length;

for (int i = 0; i < lost.length; i++) {
for (int j = 0; j < reserve.length; j++) {
// 여분을 가져왔는데, 잃어버렸을 경우, 그러면 빌려줄 수 없으니까.
if (lost[i] == reserve[j]) {
result++;
lost[i] = -1;
reserve[j] = -1;
break;
}
}

}

for (int i = 0; i < lost.length; i++) {
for (int j = 0; j < reserve.length; j++) {
if (lost[i] == reserve[j] - 1 || lost[i] == reserve[j] + 1) {
result++;
reserve[j] = -1;
break;
}
}

}
return result;
}
}

public class workoutClothes {

Solution solution;

@BeforeEach
public void 객체생성() {
solution = new Solution();
}

@Test
public void 테스트1() {
int n = 5;
int[] lost = new int[] { 2, 4 };
int[] reserve = new int[] { 1, 3, 5 };
int result = 5;
assertEquals(solution.solution(n, lost, reserve), result);
}

@Test
public void 테스트2() {
int n = 5;
int[] lost = new int[] { 2, 4 };
int[] reserve = new int[] { 3 };
int result = 4;

assertEquals(solution.solution(n, lost, reserve), result);
}

@Test
public void 테스트3() {
int n = 3;
int[] lost = new int[] { 3 };
int[] reserve = new int[] { 1 };
int result = 2;

assertEquals(solution.solution(n, lost, reserve), result);
}
}
31 changes: 31 additions & 0 deletions 200212/102092/MoreSpicy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.util.PriorityQueue;

//https://programmers.co.kr/learn/courses/30/lessons/42626

/*
1. 스코빌 지수가, 숫자대로 정렬되어야 한다는 점에서 우선순위 큐를 이용하여 풀었음.

*/

class Solution {
public int solution(int[] scoville, int K) {
PriorityQueue<Integer> pq = new PriorityQueue<>();
int answer = 0;
for(int input : scoville){
pq.add(input);
}

while(pq.peek() < K){
if(pq.size() == 1){
return -1;
}

int lowest = pq.poll();
int slowest = pq.poll();
int mix = lowest + (slowest * 2);
pq.add(mix);
answer++;
}
return answer;
}
}
11 changes: 11 additions & 0 deletions 200212/102092/groupby2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
https://programmers.co.kr/learn/courses/30/lessons/59041

SELECT NAME, COUNT(*) FROM ANIMAL_INS GROUP BY NAME HAVING COUNT(*) > 1;
null인 경우를 신경 쓰지 않아서 실패함..

SELECT NAME, COUNT(*) FROM ANIMAL_INS WHERE NAME IS NOT NULL GROUP BY NAME HAVING COUNT(NAME) > 1;

*/

SELECT NAME, COUNT(NAME) FROM ANIMAL_INS GROUP BY NAME HAVING COUNT(NAME) > 1;
40 changes: 40 additions & 0 deletions 200213/102092/RomanToInteger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
https://leetcode.com/problems/roman-to-integer/
*/

class Solution {

public int romanToInt(String s) {
int sum = 0;
if (s.contains("IV"))
sum -= 2;
if (s.contains("IX"))
sum -= 2;
if (s.contains("XL"))
sum -= 20;
if (s.contains("XC"))
sum -= 20;
if (s.contains("CD"))
sum -= 200;
if (s.contains("CM"))
sum -= 200;

for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == 'I')
sum += 1;
if (s.charAt(i) == 'V')
sum += 5;
if (s.charAt(i) == 'X')
sum += 10;
if (s.charAt(i) == 'L')
sum += 50;
if (s.charAt(i) == 'C')
sum += 100;
if (s.charAt(i) == 'D')
sum += 500;
if (s.charAt(i) == 'M')
sum += 1000;
}
return sum;
}
}
5 changes: 5 additions & 0 deletions 200213/102092/groupby3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
https://programmers.co.kr/learn/courses/30/lessons/59412
*/

SELECT HOUR(DATETIME), COUNT(DATETIME) FROM ANIMAL_OUTS WHERE HOUR(DATETIME)BETWEEN '09:00:00' AND '19:00:00' GROUP BY HOUR(DATETIME);
5 changes: 5 additions & 0 deletions 200214/102092/IsNull.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
https://programmers.co.kr/learn/courses/30/lessons/59039
*/

SELECT ANIMAL_ID FROM ANIMAL_INS WHERE NAME IS NULL;
37 changes: 37 additions & 0 deletions 200214/102092/ValidParentheses.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
https://leetcode.com/problems/valid-parentheses/
*/

import java.util.HashMap;
import java.util.Stack;

public class ValidParentheses {

Solution solution;

class Solution {

public boolean isValid(String s) {
HashMap<Character, Character> hashMap = new HashMap<>();
hashMap.put('(', ')');
hashMap.put('[', ']');
hashMap.put('{', '}');

Stack<Character> stack = new Stack();

for (int i = 0; i < s.length(); i++) {
char target = s.charAt(i);
if (target == '(' || target == '[' || target == '{') {
stack.add(target);
} else {
if (stack.isEmpty() || hashMap.get(stack.peek()) != target) {
return false;
}
stack.pop();
}

}
return stack.isEmpty();
}
}
}
5 changes: 5 additions & 0 deletions 200217/102092/IsNull2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
https://programmers.co.kr/learn/courses/30/lessons/59407
*/

SELECT ANIMAL_ID FROM ANIMAL_INS WHERE NAME IS NOT NULL;
66 changes: 66 additions & 0 deletions 200217/102092/MergeTwoSorted.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* https://leetcode.com/problems/merge-two-sorted-lists/submissions/
*
*
* public ListNode mergeTwoLists(ListNode l1, ListNode l2){
if(l1 == null) return l2;
if(l2 == null) return l1;
if(l1.val < l2.val){
l1.next = mergeTwoLists(l1.next, l2);
return l1;
} else{
l2.next = mergeTwoLists(l1, l2.next);
return l2;
}
}
- 회귀를 이용해서 푸는 방법도 있구나.
*/

class Solution {

public class ListNode {
int val;
ListNode next;

ListNode(int x) {
val = x;
}
}

public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
ListNode answer, target;

if (l1 == null && l2 == null) {
return null;
}
if (l1 == null) {
return l2;
}
if (l2 == null) {
return l1;
}

answer = new ListNode(0);
target = answer;

while (l1 != null && l2 != null) {
if (l1.val >= l2.val) {
target.next = l2;
l2 = l2.next;
} else {
target.next = l1;
l1 = l1.next;
}
target = target.next;
}

if (l1 != null) {
target.next = l1;
}
if (l2 != null) {
target.next = l2;
}
return answer.next;

}
}
5 changes: 5 additions & 0 deletions 200218/102092/IsNull3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
https://programmers.co.kr/learn/courses/30/lessons/59410
*/

SELECT ANIMAL_TYPE, IFNULL(NAME,'No name'), SEX_UPON_INTAKE FROM ANIMAL_INS;
36 changes: 36 additions & 0 deletions 200218/102092/MergeSortedArray.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
https://leetcode.com/problems/merge-sorted-array/submissions/
*/

import java.util.Arrays;

class Solution {
public void merge(int[] nums1, int m, int[] nums2, int n) {
int index = 0;
for (int i = 0; i < nums1.length; i++) {
if (nums1[i] == 0 && index < n) {
nums1[i] = nums2[index];
index++;
}
}
Arrays.sort(nums1);
}
}

/*
* - 출제자가 의도한 해답은 아니었는 듯.
* - 처음 생각은 빈곳에 num2 배열 값을 넣고, Arrays.sort를 돌리자
*
*/

// public class Solution2 {
// public void merge(int A[], int m, int B[], int n) {
// int i = m - 1, j = n - 1, k = m + n - 1;
// while (i >= 0 && j >= 0) {
// A[k--] = A[i] > B[j] ? A[i--] : B[j--];
// }
// while (j >= 0) {
// A[k--] = B[j--];
// }
// }
// }
7 changes: 7 additions & 0 deletions 200219/102092/Join1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
https://programmers.co.kr/learn/courses/30/lessons/59042
*/

SELECT OUTS.ANIMAL_ID , OUTS.NAME FROM ANIMAL_INS AS INS
RIGHT JOIN ANIMAL_OUTS AS OUTS ON INS.ANIMAL_ID = OUTS.ANIMAL_ID
WHERE INS.ANIMAL_ID IS NULL;
Loading