Skip to content

Commit f877e53

Browse files
committed
Typo fix - Explanation
1 parent 2e91c64 commit f877e53

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

Defanging IP Address/EfficientSolution.py

+9-22
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,22 @@
55
## Problem: 1108
66
## Problem Name: Defanging an IP Address
77
##===================================
8-
#Given a non-negative integer num, return the number of steps to reduce it to zero.
8+
#Given a valid (IPv4) IP address, return a defanged version of that IP address.
99
#
10-
#If the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it.
11-
#Example 1:
10+
#A defanged IP address replaces every period "." with "[.]".
1211
#
13-
#Input: num = 14
14-
#Output: 6
15-
#Explanation:
16-
#Step 1) 14 is even; divide by 2 and obtain 7.
17-
#Step 2) 7 is odd; subtract 1 and obtain 6.
18-
#Step 3) 6 is even; divide by 2 and obtain 3.
19-
#Step 4) 3 is odd; subtract 1 and obtain 2.
20-
#Step 5) 2 is even; divide by 2 and obtain 1.
21-
#Step 6) 1 is odd; subtract 1 and obtain 0.
12+
#Example 1:
2213
#
14+
#Input: address = "1.1.1.1"
15+
#Output: "1[.]1[.]1[.]1"
2316
#Example 2:
2417
#
25-
#Input: num = 8
26-
#Output: 4
27-
#Explanation:
28-
#Step 1) 8 is even; divide by 2 and obtain 4.
29-
#Step 2) 4 is even; divide by 2 and obtain 2.
30-
#Step 3) 2 is even; divide by 2 and obtain 1.
31-
#Step 4) 1 is odd; subtract 1 and obtain 0.
18+
#Input: address = "255.100.50.0"
19+
#Output: "255[.]100[.]50[.]0"
3220
#
33-
#Example 3:
21+
#Constraints:
3422
#
35-
#Input: num = 123
36-
#Output: 12
23+
#The given address is a valid IPv4 address.
3724

3825
class Solution:
3926

0 commit comments

Comments
 (0)