Computer NetworksNETWORKS

GFG-POTD | Validate an IP Address using Java | 06 August 2024 | Practice | String | Data Structure

Geeks-for-Geeks | Practice Problem
06 August 2024
Problem : Validate an IP Address using Java
Level : Medium
Language : Java
Topics Tag : Strings | Data Structure

____________________________________

⬇️ You may also visit my another playlists :

👉 LeetCode Problems :

👉 Code360 by coding ninja’s mcq solution :

👉 Geeks-for-Geeks :

———————————————————-

Stay connected with me on social media for more updates and behind-the-scenes content !

You can find me on 🔍:

📱 Instagram Profile :
https://www.instagram.com/_ganesh_p09

🌐 LinkedIn Profile :
https://www.linkedin.com/in/ganesh-prasad09

—————————————————————–

➡️ Problem Statement as follows :

You are given a string str in the form of an IPv4 Address. Your task is to validate an IPv4 Address, if it is valid return true otherwise return false.

IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers, each ranging from 0 to 255, separated by dots, e.g., 172.16.254.1

A valid IPv4 Address is of the form x1.x2.x3.x4 where 0 = (x1, x2, x3, x4) = 255. Thus, we can write the generalized form of an IPv4 address as (0-255).(0-255).(0-255).(0-255)

Note: Here we are considering numbers only from 0 to 255 and any additional leading zeroes will be considered invalid.

Examples :

Input: str = 222.111.111.111

Output: true

Explanation: Here, the IPv4 address is as per the criteria mentioned and also all four decimal numbers lies in the mentioned range.

Input: str = 5555..555

Output: false

Explanation: 5555..555 is not a valid. IPv4 address, as the middle two portions are missing.

Expected Time Complexity: O(n)
Expected Auxiliary Space: O(1)

———————————————

🔔 If you enjoyed the content, please subscribe to the channel for more updates! 📺

👍 If you found this video helpful, don’t forget to give it a thumbs up and share it with your friends! 📤

🙏 Thank you for watching the video! 😊

————————————————

📚 Check out other problems! 🔍:

🧩 1. Partitions with Given Difference | Java | GeekforGeeks | Practice Problem

🧩 2. K-Palindrom | Java | GeeksforGeeks | Practice Problems

🧩 3. [ Part-02 ] Maximum Score Words Formed by Letters – Leetcode

🧩4. Mobile Numeric Keypad :

🧩 5. Boring Factorial ( Coding Ninjas ) :

🧩 6. Coverage of all Zeros in a binary matrix

🧩 7. Make Binary Tree From Linked List :

————————————————–

#gfgproblems | #gfgproblemoftheday | #problemofthedaygfg | #ValidateanIPAddress | #ValidateanIPAddressusingjava | #ValidateanIPAddressproblemoftheday | #ValidateanIPAddressproblemsolution | #ValidateanIPAddressusingjavasolution | #ValidateanIPAddressjavasolution | #ValidateanIPAddresspracticeproblem
| #ValidateanIPAddresssolutionusingjava

source

ipv4

Alice AUSTIN

Alice AUSTIN is studying Cisco Systems Engineering. He has passion with both hardware and software and writes articles and reviews for many IT websites.