Skip to content

튜플 #69

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

Merged
merged 1 commit into from
Jul 1, 2022
Merged

튜플 #69

merged 1 commit into from
Jul 1, 2022

Conversation

NamJwong
Copy link
Owner

@NamJwong NamJwong commented Jul 1, 2022

문제

풀이 후기

문제에 도저히 이해가 안가는 부분이 있어서 프로그래머스의 '질문하기'를 보고 힌트를 얻어 풀었다..
내가 문제에서 놓친 부분이 있는 것이었다ㅠ 꼼꼼히 읽는다고 읽었는데..

문제를 이해한 후로는 고민 없이 풀었다.

다른 사람의 풀이와 비교

좋아요 1등 풀이

function solution(s) {
    return JSON.parse(s.replace(/{/g, '[').replace(/}/g, ']'))
    .sort((a, b) => a.length - b.length)
    .reduce((arr, v, n) => {
        if (n) {
            return arr.concat(v.filter(f => !arr.includes(f)));
        }
        return v;
    }, []);
}
  • JSON.parse 쓰면 간단하게 배열로 만들 수 있었네,,
  • 대박 이게 내 풀이 방식보다 훨씬 똑똑한 방법 같다

@NamJwong NamJwong self-assigned this Jul 1, 2022
@NamJwong NamJwong merged commit 0bd34ac into main Jul 1, 2022
@NamJwong NamJwong deleted the algorithm/#67 branch July 1, 2022 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

튜플
1 participant