updated at 2022. 12. 16. 오전 12:39:12
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
// [문제 링크]: https://school.programmers.co.kr/learn/courses/30/lessons/42862#
|
// [문제 링크]: https://school.programmers.co.kr/learn/courses/30/lessons/42862
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -7,14 +7,11 @@ class Solution {
|
|||||||
for(int i : list){
|
for(int i : list){
|
||||||
int c = ha.get(i);
|
int c = ha.get(i);
|
||||||
if(c == 0) {
|
if(c == 0) {
|
||||||
System.out.println("00"+i+" : "+c);
|
|
||||||
if (i < n && ha.get(i+1) == 2){
|
if (i < n && ha.get(i+1) == 2){
|
||||||
ha.put(i+1,1);
|
ha.put(i+1,1);
|
||||||
System.out.println(i+1+" : "+1);
|
|
||||||
ha.put(i, 1);
|
ha.put(i, 1);
|
||||||
} else if(i > 1 && ha.get(i-1) == 2) {
|
} else if(i > 1 && ha.get(i-1) == 2) {
|
||||||
ha.put(i-1,1);
|
ha.put(i-1,1);
|
||||||
System.out.println(i-1+" : "+1);
|
|
||||||
ha.put(i, 1);
|
ha.put(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,7 +24,6 @@ class Solution {
|
|||||||
ArrayList<Integer> lab = new ArrayList<>();
|
ArrayList<Integer> lab = new ArrayList<>();
|
||||||
for(int i = 1; i <= n; i++){
|
for(int i = 1; i <= n; i++){
|
||||||
ha.put(i,1);
|
ha.put(i,1);
|
||||||
System.out.println(i);
|
|
||||||
}
|
}
|
||||||
for(int i : lost){
|
for(int i : lost){
|
||||||
ha.put(i, ha.get(i)-1);
|
ha.put(i, ha.get(i)-1);
|
||||||
@@ -37,30 +33,24 @@ class Solution {
|
|||||||
ha.put(i, c+1);
|
ha.put(i, c+1);
|
||||||
}
|
}
|
||||||
for(int i : lost){
|
for(int i : lost){
|
||||||
System.out.println("TestOn");
|
|
||||||
if(ha.get(i) == 1) {
|
if(ha.get(i) == 1) {
|
||||||
System.out.println("breaked by 1 and i = "+i);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for(int j : reserve){
|
for(int j : reserve){
|
||||||
if(Math.abs(i-j)==1) count += ha.get(j);
|
if(Math.abs(i-j)==1) count += ha.get(j);
|
||||||
}
|
}
|
||||||
System.out.println(i+" cou"+count);
|
|
||||||
if(count >= 4) {
|
if(count >= 4) {
|
||||||
lab.add(i);
|
lab.add(i);
|
||||||
} else if(count >= 1){
|
} else if(count >= 1){
|
||||||
laa.add(i);
|
laa.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println(lab);
|
|
||||||
System.out.println(laa);
|
|
||||||
rl(laa, ha, n);
|
rl(laa, ha, n);
|
||||||
rl(lab, ha, n);
|
rl(lab, ha, n);
|
||||||
for(int i = 1; i <= n; i++){
|
for(int i = 1; i <= n; i++){
|
||||||
answer += (ha.get(i) > 0) ? 0 : 1;
|
answer += (ha.get(i) > 0) ? 1 : 0;
|
||||||
System.out.println(i+" : "+ha.get(i));
|
|
||||||
}
|
}
|
||||||
return n - answer;
|
return answer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user