릿코드(LEETCODE)
-
decompress run length encoded list릿코드(LEETCODE) 2020. 2. 3. 16:18
https://leetcode.com/problems/decompress-run-length-encoded-list 불러오는 중입니다... 입력으로 들어오는 배열은 페어의 의미로 바라본다. RLE 알고리즘에 이해가 필요 한대 어렵지 않다. 2A3B4C 가 있다면 RLE 인코딩을 해제한다면 AABBBCCCC 가 된다. 최초의 코드는 아래와 같다. class Solution { public: vector decompressRLElist(vector& nums) { vector arr; for (int i = 0; i < nums.size(); i += 2) { int cand = nums[i]; int d = nums[i + 1]; for (int j = 0; j < cand; j++) { arr.push_..
-
defanging-an-ip-address릿코드(LEETCODE) 2020. 2. 3. 16:02
https://leetcode.com/problems/defanging-an-ip-address/ Defanging an IP Address - 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 단순 치환 문제 좀더 이쁘게 하는 방법이 없으려나 class Solution { public: string defangIPaddr(string address) { string s; for (int i = 0; i < address.size(); i++) { char ch =..