728x90

 

* 회사 직원분이 해보자고 해서, 어떻게든 해서 결과는 나왔는데.... 효율성이 제로 ㅜㅜ 

  다시 수정해서 어떻게든 효율성을 올려볼 예정임... (정식적으로 배우지 않은티가 너무 나는게 함정;;;)

function solution(info, query) {
    var answer = [];
    let count = 0;
    let number = 0;
    
    let infoObj = [];
    let queryObj = [];
     
    info.forEach((element, index) => {
        infoObj.push(element.split(' '));        
    })            

    query.forEach((element, index) =>{
        const list = element.split(' and ')
        const list2 = list[3].split(' ');
        list.pop();
        list.push(list2[0]);
        list.push(list2[1]);
        queryObj.push(list);   
    })      
       
     
    for(let i=0 ; i< queryObj.length ; i++)
    {
        for(let j=0 ; j< infoObj.length ; j++)
        {   
            if (parseInt(infoObj[j][4]) >= parseInt(queryObj[i][4]))
            {                              
                for(let k=0; k<4 ; k++){
                    if(queryObj[i][k] == '-')
                    { 
                        count += 1;                     
                    } else if (infoObj[j][k] == queryObj[i][k])
                        {
                            count += 1;                    
                        } 
                     
                    if (count > 3){   
                        number += 1 ;  
                         count = 0;
                    }                
                 }
                 count = 0;
            }
          }   
        answer.push(number);     
        number = 0;
    }
    return answer;   
}

+ Recent posts