모든 챌린지
쉬움 0명 해결 정답률 0%

Initials From a Name

Build uppercase initials from a full name.

배우게 될 내용

  • 이름을 단어로 나누기
  • 각 단어의 첫 글자 가져오기
  • 합친 뒤 대문자로 만들기

문제

Take the first letter of each word in full_name, uppercase it, and join the letters. Words are separated by one or more spaces.

Implement initials(full_name).

Input

full_name: A name made of letters and spaces.

Output

Return the initials, for example "ADL".

제약 조건

1 ≤ length of full_name ≤ 200; it contains at least one letter

예시

예시 1
입력:
full_name = "Ada Lovelace"

예상 출력:
expected = "AL"
입력:
std::string full_name = "Ada Lovelace";

예상 출력:
std::string expected = "AL";
입력:
string full_name = "Ada Lovelace";

예상 출력:
string expected = "AL";

설명

A from Ada and L from Lovelace: "AL".

예시 2
입력:
full_name = "grace  brewster  hopper"

예상 출력:
expected = "GBH"
입력:
std::string full_name = "grace  brewster  hopper";

예상 출력:
std::string expected = "GBH";
입력:
string full_name = "grace  brewster  hopper";

예상 출력:
string expected = "GBH";

설명

Extra spaces don't matter; the initials are uppercased: "GBH".

접근 방법

먼저 스스로 풀어 본 뒤 힌트를 하나씩 열어 보세요.

힌트 1

각 단어는 첫 글자 하나만 기여합니다.

힌트 2

공백 뒤에서 새 단어가 시작하는 지점을 추적하면서 이름을 훑으세요.

힌트 3

연속된 공백이 있어도 단어마다 이니셜 하나만 가져가도록 주의하세요.

예상 복잡도

시간 O(n), 추가 공간 O(1)

참고 자료

이 문제는 CodeUtility에 맞게 수정되었습니다. 위의 설명과 제한 조건을 따르세요.

다른 사람의 풀이 보기

커뮤니티 솔루션

아직 공개된 풀이가 없습니다. 문제를 풀고 첫 풀이를 공유하세요.