Notice
Recent Posts
Recent Comments
Link
코딩 공부
코딩 인터뷰 퀘스천 완전 분석 - Reformat The String 본문
[LeetCode] [Easy] 1417. Reformat The String
leetcode.com/problems/reformat-the-string/
Reformat The String - 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
문자열 변경하기
문자열속에 나온 문자와 숫자를 번갈아가면서 나오도록 바꿔서 리턴하는게 문제에요. 조합이 나올수 없다면 빈 문자열을 리턴해주세요.
문자열에 있는 문자와 숫자를 나눠서 저장해두고 길이가 2 이상 차이나면 맞는 조합이 없어서 바로 빈 문자열 리턴합니다. 그 후에는 문자와 숫자 갯수를 비교해서 더 긴쪽이 먼저 나오도록 만들어주면 완성이에요.
코드를 쓰면서 너무 조잡한 방법같다는 찝찝함이 사라지질 않네요... ㅋㅋㅋㅋ 그래도 지난번에 기억해둔 StringBuilder을 사용해서 속도는 조금 높였어요.
'Coding' 카테고리의 다른 글
코딩 인터뷰 퀘스천 완전 분석 - Valid Anagram (0) | 2020.10.27 |
---|---|
코딩 인터뷰 퀘스천 완전 분석 - Isomorphic Strings (0) | 2020.10.26 |
코딩 인터뷰 퀘스천 완전 분석 - Binary Number with Alternating Bits (0) | 2020.10.23 |
코딩 인터뷰 퀘스천 완전 분석 - Maximum Product of Two Elements in an Array (0) | 2020.10.22 |
코딩 인터뷰 퀘스천 완전 분석 - Matrix Diagonal Sum (0) | 2020.10.21 |
Comments