-
defanging-an-ip-address릿코드(LEETCODE) 2020. 2. 3. 16:02반응형
https://leetcode.com/problems/defanging-an-ip-address/
단순 치환 문제
좀더 이쁘게 하는 방법이 없으려나
class Solution { public: string defangIPaddr(string address) { string s; for (int i = 0; i < address.size(); i++) { char ch = address[i]; if (ch == '.') { s.push_back('['); s.push_back('.'); s.push_back(']'); } else { s.push_back(ch); } } return s; } };
반응형'릿코드(LEETCODE)' 카테고리의 다른 글
1323. Maximum 69 Number (0) 2020.02.03 Split a String in Balanced Strings (0) 2020.02.03 subtract the product and sum of digits of an integer submissions (0) 2020.02.03 find numbers with even number of digits (0) 2020.02.03 decompress run length encoded list (0) 2020.02.03