Skip to content

Conversation

@suhwan2004
Copy link
Collaborator

문제

Type Info
Time Complexity O(N)
Space Complexity O(N)
Algorithm for
Data Structure hash Set, String

Constraints

  • 1 <= word.length <= 1000
  • 주어지는 word는 숫자와 영소문자로 구성된다

Edge Case

x

풀이

  1. 입력받은 word를 for로 길이만큼 순회한다.
  2. 1의 내부에서 다음과 같은 조건식을 거친다
  • 만약, 현재 문자가 소문자자 일 시
    • 만약, 기존에 저장해둔 숫자가 있다면 hash set에 해당 숫자 저장 후, 저장용 숫자변수 초기화
  • 만약, 소문자가 아니며, 저장된 숫자가 없는데 0이 나왔을 시
    • 다음 문자가 영문자이면 0 자체만으로도 숫자가 될 수 있기에 숫자변수에 저장.
  • 마지막으로, 그냥 숫자일 경우
    • 숫자변수에 저장
  1. for을 다 돌고 나서도 숫자변수가 존재할 수도 있기에 체킹 후 hash set에 숫자 저장
  2. hash set의 길이를 반환 => 각각 다른 숫자 유형의 갯수가 반환됨

어려웠던 점

x

알게된 점

x

@suhwan2004 suhwan2004 self-assigned this Jan 3, 2025
@github-actions github-actions bot enabled auto-merge (squash) January 12, 2025 01:39
@github-actions github-actions bot merged commit 2b1d24d into main Jan 12, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants