dev._.note

[TIL] 231027_TIL 본문

TIL (Today I Learned)

[TIL] 231027_TIL

Laena 2023. 10. 27. 20:50
🌈 알고리즘을 풀이할 때 Array를 사용하면 런타임에러가 나는 부분을 수정.
같은 답이 나와도 계속 에러가 떠서 따로 선언하고 사용하니 통과가 되었다.
휴대폰번호 끝 4자리만 보여주고 나머지는 '*'처리하는 문제를 풀었는데 공부하다가 suffix메소드를 사용해 푸는 법을 공부했다.
뒤에서 부터 처리하는 suffix메소드를 공부하다가 앞에서부터 처리하는 preffix메소드도 함께 정리했다.
앞자리 '*'을 표시하기위해 반복문으로 코드를 짜다가 새로 알게된 init(repeating:count:)으로 문자열을 지정된 횟수만큼 반복해서 새 문자열을 만들수 있었다.

🌈 새로 알게 된 부분
  ⭐️ init(repeating:count:)로 지정된 횟수만큼 반복해서 새 문자열 만들기.
  ⭐️ preffix와 suffix 메소드 사용법.

🌈 배움이 필요한 부분
  ⭐️ bool배열을 단축인자로 구별하는 법

 

👏 새로 알게 된 부분

⭐️ init(repeating:count:)

https://how-mrk.tistory.com/entry/Swift-initrepeatingcount

 

[Swift] init(repeating:count:)

init(repeating:count:) Creates a new string representing the given string repeated the specified number of times. 지정된 횟수만큼 반복된 주어진 문자열을 나타내는 새 문자열을 만듭니다. String과 Array에서 사용할 수 있다

how-mrk.tistory.com

 

⭐️ preffix와 suffix 메소드

https://how-mrk.tistory.com/entry/Swift-prefix-%EC%99%80-suffix

 

[Swift] prefix 와 suffix

📌 prefix 4가지 종류 prefix(_ maxLength: Int) prefix(upTo end: Int) prefix(through position: Int) prefix(while predicate: (Element) -> Bool) ⭐️ prefix(_ maxLength: Int) prefix(_:) | Apple Developer Documentation Returns a subsequence, up to the s

how-mrk.tistory.com

 

👏 코딩테스트 풀이

https://github.com/mirae0312/Programmers_Algorithm/tree/main/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4/1

'TIL (Today I Learned)' 카테고리의 다른 글

[TIL] 231031_TIL  (0) 2023.10.31
[TIL] 231030_TIL  (1) 2023.10.30
[TIL] 231026_TIL  (0) 2023.10.26
[TIL] 231025_TIL  (0) 2023.10.25
[TIL] 231024_TIL  (0) 2023.10.24