Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lv.2] 뒤에 있는 큰 수 찾기 #167

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[Lv.2] 뒤에 있는 큰 수 찾기 #167

wants to merge 1 commit into from

Conversation

say-young516
Copy link
Contributor

🔗 Related Issues

🔍 문제

프로그래머스 - 뒤에 있는 큰 수 찾기

✅ 풀이 방법

추후 첨부

📜 최종 소스코드

function solution(numbers) {
    const answer = new Array(numbers.length).fill(-1);  
    for(let i=numbers.length-2;i>=0;i--){
        for(let j=i+1;j<numbers.length;j++){
            if(numbers[i]<numbers[j]){
                answer[i]=numbers[j];
                break;
            }
            else{
                if(numbers[i]<answer[j]){
                    answer[i]=answer[j];
                    break;
                }else if(answer[j]===-1) break;
            }   
        }
    }
    
    
    return answer;
}

@say-young516 say-young516 self-assigned this May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lv.2] 뒤에 있는 큰 수 찾기
1 participant