FastPrepIPv4 Address Classification
Problems/IPv4 Address Classification

IPv4 Address Classification

Rippling logoRippling● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Rippling online assessment. The report gives batch IPv4 validation and all five region boundaries, including 0 through 127 in region 1. This function takes one address at a time. We kept the rule on leading zeros and the wider limits for invalid ASCII input. Our version is about 95% the same as the reported question.

Given a string address, determine its class as an IPv4 address.

A valid address for this exercise has exactly four dot-separated parts. Every part must contain one to three ASCII decimal digits and have a numeric value from 0 through 255, inclusive. Leading zeros are allowed.

After validating all four parts, classify by the first part:

  • Return 1 for 0..127.
  • Return 2 for 128..191.
  • Return 3 for 192..223.
  • Return 4 for 224..239.
  • Return 5 for 240..255.

Return -1 for an invalid address. First-part values zero and 127 are valid members of class 1.

Function

classifyIpAddress(address: String) → int

Examples

Example 1

address = "10.20.30.40"return = 1

All four parts are valid, and the first part, 10, is in the range for class 1.

Example 2

address = "192.168.1.1"return = 3

The first part is 192, so the valid address belongs to class 3.

Example 3

address = "127.0.0.1"return = 1

The first part 127 is included in class 1, whose range is zero through 127.

Example 4

address = "10.20.300.40"return = -1

The third part is greater than 255, so the address is invalid.

Constraints

  • 1 <= address.length <= 100
  • address contains ASCII characters.

More Rippling Online Assessment questions

  • Most Segments That Sort the ArrayOA · Seen Nov 2026
  • Palindromic Paths to the RootOA · Seen Nov 2026
  • Server InvestmentOA · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • REST API: Highest International StudentsOA · Seen Sep 2026
  • Token ValidationOA · Seen Sep 2026
  • Consistent LogsOA · Seen Sep 2026
  • Costliest ChocolateOA · Seen Sep 2026
  • Server ManagementOA · Seen Sep 2026
  • Cyber Beacon DetectionOA · Seen Aug 2026

Similar questions at other companies

  • Scale Ingredient QuantitiesUpstart · OAUpstart interview questions
  • Generate Table of ContentsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Incident MonitorStripe · OAStripe interview questions
  • Correct Apartment Bedroom CountsRamp · OARamp interview questions
  • Hidden ArtifactsIMC Trading · OAIMC Trading interview questions
  • Build a Profile Sentence from CSVAirbnb · OAAirbnb interview questions
  • Restricted Decimal Number ValidatorLinkedIn · PHONE SCREENLinkedIn interview questions
  • Extensible Grep Line FilterBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Format CSV Rows as an ASCII TableAmazon · PHONE SCREEN
  • Compare Calendar DatesWells Fargo · PHONE SCREENWells Fargo interview questions

Interview reports that mention this question

  • Rippling Intern Interview History: 17 Experiences (Part 5 of 5)

Rippling interview experiences

  • Rippling Senior SWE Full Loop Questions: 1 Experience
  • Rippling Experienced SWE Phone Screens: 2 Experiences
  • Rippling Design Rounds and Onsites: 17 Experiences (Part 3 of 3)
  • Rippling Phone Coding Screens: 14 Experiences (Part 2 of 3)
  • Rippling SWE Screens and Loops: 31 Experiences (Part 1 of 3)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public int classifyIpAddress(String address) {
        // write your code here
    }
}
Checking account…