인프런 커뮤니티 질문&답변
문제처럼 N개의 단어가 들어온다면 배열이라고 생각하고 풀어도 될까요?
작성
·
237
0
문제에는 프로그래머스 처럼 배열로 들어온다는 내용이 없었는데 풀이를 보니까 배열로 처음부터 작성하고 푸시네요.
이런 힌트 조차 잡아내서 풀어야하는걸까요??
감사합니다
퀴즈
What is the most efficient way to count the total number of specific characters in a string, ignoring case?
Iterate through the string and compare each character to both the uppercase and lowercase of the target character.
Convert the entire string to a single case (e.g., all uppercase) and count the characters.
Count uppercase and lowercase letters respectively and sum them.
Using a Set data structure, store characters without duplicates and then count them.
답변 1
1
꼭 N개의 단어가 들어온다는 말로 배열로 작성해야하는 것은 아닙니다.
상황에 따라서는 Set 이나 Map 등의 다른 자료구조를 사용해야 할 수도 있습니다.
하지만 일반적으로는 N개의 단어를 입력받을 때마다 처리하려는 것이 아니라면
그것을 특정 공간에 저장할 필요가 있습니다. 그런 상황에서 가장 일반적으로 사용되는 것이 "배열"입니다.





