728x90

알고리즘/해결 43

LeetCode 1281. Subtract the Product and Sum of Digits of an Integer

1.문제(원본) Given an integer number n, return the difference between the product of its digits and the sum of its digits Example 1: Input: n = 234 Output: 15 Explanation: Product of digits = 2 * 3 * 4 = 24 Sum of digits = 2 + 3 + 4 = 9 Result = 24 - 9 = 15 Example 2: Input: n = 4421 Output: 21 Explanation: Product of digits = 4 * 4 * 2 * 1 = 32 Sum of digits = 4 + 4 + 2 + 1 = 11 Result = 32 - 11 = ..

알고리즘/해결 2020.01.13

LeetCode 1108. Defanging an IP Address

1.문제(원본) Given a valid (IPv4) IP address, return a defanged version of that IP address. A defanged IP address replaces every period "." with "[.]". Example 1: Input: address = "1.1.1.1" Output: "1[.]1[.]1[.]1" Example 2: Input: address = "255.100.50.0" Output: "255[.]100[.]50[.]0" Constraints: The given address is a valid IPv4 address. 2.문제 특정 문자를 다른 형태로 변환해서 새로운 문자열을 만든다 3.나의 생각 class Solution ..

알고리즘/해결 2020.01.12
728x90