FastPrepValidate Email Address
Problems/Validate Email Address

Validate Email Address

Accenture logoAccenture● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names an email-validation task but does not say which email format is accepted. Our version is about 72% the same as the reported question.

You are given a string email. Return true if it follows all of these rules, and false otherwise:

  • It contains exactly one @.
  • The local part is the text before @. It is nonempty and uses only lowercase letters, digits, dots, underscores, and hyphens.
  • The domain is the text after @. It has at least two nonempty labels separated by dots.
  • Each domain label uses only lowercase letters, digits, and hyphens. A label cannot begin or end with a hyphen.

These are simple rules made for this exercise. They are not the full RFC email standard.

Function

isValidEmail(email: String) → boolean

Examples

Example 1

email = "dev.team@example.com"return = true

The address has one @, a valid local part, and two valid domain labels.

Example 2

email = "userexample.com"return = false

The address does not contain an @.

Example 3

email = "user@-example.com"return = false

The first domain label begins with a hyphen.

Constraints

  • 1 <= email.length <= 10^5.
  • email contains ASCII characters.

More Accenture interview questions

  • Nearest Composite NumberOA · Seen Sep 2026
  • Minimum Password IncrementsOA · Seen Sep 2026
  • Reduce a Number to One DigitOA · Seen Sep 2026
  • Candy DistributionOA · Seen Sep 2026
  • Customers Who Never OrderedOA · Seen Sep 2026
  • Economical TripOA · Seen Sep 2026
  • Coin ChangeOA · Seen Sep 2026
  • Closest Rhyming WordOA · Seen Aug 2026
  • Array Leader ElementsOA · Seen Nov 2025
  • Alternating Index Square SumONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Total Each Letter's Count in an Encoded StringIBM · OAIBM interview questions
  • Count Valid Space-Delimited WordsVisa · OAVisa interview questions
  • Scale Ingredient QuantitiesUpstart · OAUpstart interview questions
  • Is This Date a Weekend?Salesforce · OASalesforce interview questions
  • FIX Message ReconciliationVirtu Financial · OAVirtu Financial interview questions
  • IPv4 Address ClassificationRippling · OARippling interview questions
  • Generate Table of ContentsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Highest-Ranked University by CountryAgoda · OAAgoda interview questions
  • Counterfeit CurrencyBox · OABox interview questions
  • Convert Snake Case Variables to Camel CaseRamp · OARamp interview questions

Accenture interview experiences

  • Accenture New Grad ASE OA Questions: 15 Experiences
All Accenture interview questionsSee Accenture hiring insights
Saved
class Solution {
    public boolean isValidEmail(String email) {
        // Write your code here.
    }

}
Checking account…