Created
          July 7, 2020 11:29 
        
      - 
      
- 
        Save dalcon10028/17ea7a1cffad9ca4c0886d16c845c97c to your computer and use it in GitHub Desktop. 
    프로그래머스 코딩테스트 연습 Level1 - 같은 숫자는 싫어 [ Java ]
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import java.util.LinkedList; | |
| public class Solution { | |
| public static void main(String[] args) { | |
| int[] arr = new int[]{1, 1, 3, 3, 0, 1, 1}; | |
| int[] r = solution(arr); | |
| for (int i : r) | |
| System.out.println(i); | |
| } | |
| static int[] solution(int[] arr) { | |
| LinkedList<Integer> list = new LinkedList<>(); | |
| for (Integer i : arr) { | |
| if(!list.isEmpty() && list.getLast()==i) | |
| continue; | |
| list.add(i); | |
| } | |
| return list.stream().mapToInt(i->i).toArray(); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment