Skip to content

[Algorithm] 수박수박수박수박수박수? #54

Description

@hwangJi-dev

💬 문제

[코딩테스트 연습 - 수박수박수박수박수박수?](https://school.programmers.co.kr/learn/courses/30/lessons/12922)


💬 Idea

  • n / 2의 나머지가 0이라면 몫만큼 “수박”을 반복해서 문자열에 더한다.
  • n / 2의 나머지가 1이라면 몫만큼 “수박”을 반복해서 문자열에 더하고 추가로 “수”를 더한다.

💬 풀이

func solution(_ n:Int)->String{return n %2==0?String(repeating:"수박", count: n /2):String(repeating:"수박", count: n /2)+""}

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