코딩테스트/[C#] 프로그래머스

[프로그래머스 | C# | Lv.0] 할 일 목록

냠냠쿠 2023. 9. 7. 21:10
728x90

 

https://school.programmers.co.kr/learn/courses/30/lessons/181885

 

 

📝 나의 풀이

using System;

public class Solution {
    public string[] solution(string[] todo_list, bool[] finished) {
        
        int cnt = 0;
        foreach(bool i in finished){
            if(i==false){
                cnt++;
            }
        }
        string[] answer = new string[cnt];
        
        int index =0;
        
        for(int i=0; i<finished.Length; i++){
            if(finished[i]!=true) {
                answer[index] = todo_list[i];
                index++;
            }
        }
        
        return answer;
    }
}
728x90