Bunker
[easy] 771. Jewels and Stones 본문
문제
https://leetcode.com/problems/jewels-and-stones/
Jewels and Stones - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
풀이
간단한 문자 변환 프로그램이다.
A~Z, a~z만 입력되므로, 이를 53크기 int 배열에 넣고 유/무를 기록해서 stone_count 증가에 사용했다.
(index 0은 헷갈려서 사용하지 않았으므로 53크기로 선언함)
고찰
leetcode 풀 때의 주의점*
회사 시험과 마찬가지로... 단일 testcase (test)시 정답이 나오더라도, submission시에는 동일한 배열을 사용하게 되므로,
TC 수행 시 마다 공통 배열은 초기화해줘야 한다.
코드
https://github.com/suy-lee/algorithm/blob/master/LeetCode_JewelsAndStones.c
'Algorithms > Leetcode' 카테고리의 다른 글
[medium] 54. Spiral Matrix (0) | 2022.08.02 |
---|---|
[hard] 41. First Missing Positive (0) | 2022.07.25 |
[medium] 238. Product of Array Except Self (0) | 2022.07.25 |
Youtube Searching Script (Javascript) (0) | 2018.05.07 |