Skip to content

[Algorithm] 가장 큰 수 #198

Description

@hwangJi-dev

💬 문제

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


💬 Idea

  • sorted(by:) 메서드를 응용하는 방법에 대해서 더 깊이 알게 되었다.
    • 두 수를 더한 합이 더 크도록 정렬하면 되는 문제였다.!!!!!!!

💬 풀이

import Foundation
func solution(_ numbers:[Int])->String{letarr= numbers.sorted(by:{Int(String($0)+ String($1))! >Int(String($1)+ String($0))! })if arr.allSatisfy({ $0 ==0}){return"0"}else{return arr.map({String($0)}).joined()}}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions