updated at 2022. 12. 17. 오후 6:48:06
This commit is contained in:
@@ -3,10 +3,9 @@
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
public class Solution {
|
public class Solution {
|
||||||
public int[] solution(int []arr) {
|
public int[] solution(int []arr) {
|
||||||
Queue<Integer> q = new LinkedList<Integer>();
|
LinkedList<Integer> q = new LinkedList<Integer>();
|
||||||
for(int b : arr){
|
for(int b : arr){
|
||||||
Object peek = ((LinkedList<Integer>)q).peekLast();
|
if(q.peekLast() != null && b == q.peekLast()) continue;
|
||||||
if(peek != null && b == (int)peek) continue;
|
|
||||||
else q.add(b);
|
else q.add(b);
|
||||||
}//list 상태에서도 가능하지만 array가 수요이니 array로 변환합니다.
|
}//list 상태에서도 가능하지만 array가 수요이니 array로 변환합니다.
|
||||||
return q.stream().mapToInt(Integer::intValue).toArray();
|
return q.stream().mapToInt(Integer::intValue).toArray();
|
||||||
|
|||||||
Reference in New Issue
Block a user