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

[Algorithm] 핸드폰 번호 가리기 #78

Closed
hwangJi-dev opened this issue Jan 18, 2023 · 0 comments
Closed

[Algorithm] 핸드폰 번호 가리기 #78

hwangJi-dev opened this issue Jan 18, 2023 · 0 comments

Comments

@hwangJi-dev
Copy link
Owner

hwangJi-dev commented Jan 18, 2023

💬 문제

[코딩테스트 연습 - 핸드폰 번호 가리기](https://school.programmers.co.kr/learn/courses/30/lessons/12948)


💬 Idea

  • phone_number의 마지막 4자리를 제외한 count만큼 *를 Repeating한 String을 만든다.
  • 해당 String에 phone_number의 마지막 4자리를 더한다 (suffix 사용)

💬 풀이

func solution(_ phone_number:String) -> String {
    return String(repeating: "*", count: phone_number.count - 4) + phone_number.suffix(4)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant