Skip to content

[Algorithm] 바탕화면 정리 #122

Description

@hwangJi-dev

💬 문제

바탕화면 정리


💬 Idea

  • 최소 좌표는 최소좌표대로, 최대 좌표는 최대 좌표대로 저장할 coordinate 변수를 만든다.
  • # 문자가 나올 시 coordinate의 0,1,2,3 인덱스에 min, max값을 비교하여 저장해준다.

💬 풀이

import Foundation
func solution(_ wallpaper:[String])->[Int]{varcoordinate=[50,50,0,0]for(idx, i)in wallpaper.enumerated(){for(jdx, j)in i.enumerated(){if j =="#"{coordinate[0]=min(idx,coordinate[0])coordinate[1]=min(jdx,coordinate[1])coordinate[2]=max(idx +1,coordinate[2])coordinate[3]=max(jdx +1,coordinate[3])}}}return coordinate
}

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