FastPrepFilter Contacts by Email Domain
Problems/Filter Contacts by Email Domain

Filter Contacts by Email Domain

Stripe logoStripe● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Stripe new-grad onsite interview. The source says to return contact information whose email matches a domain. It does not give the row layout, how to clean up values, what to do with bad input, or the order. Our version is about 78% the same as the reported question.

You are given contact rows and a requested email domain. Each contact row has the form name,email,phone.

Return every original contact row whose email has exactly one @, a non-empty local part, and a domain equal to the requested domain using case-insensitive comparison. The requested domain may optionally begin with @.

Preserve the contacts' input order. Ignore malformed contact rows and malformed email addresses.

Function

filterContactsByDomain(contacts: String[], domain: String) → String[]

Examples

Example 1

contacts = ["Alice,alice@example.com,111","Bob,bob@other.com,222","Cara,cara@EXAMPLE.COM,333"]domain = "example.com"return = ["Alice,alice@example.com,111","Cara,cara@EXAMPLE.COM,333"]

Alice and Cara have the requested domain. Domain comparison is case-insensitive, and their original rows and order are preserved.

Example 2

contacts = ["A,a@shop.io,1","B,b@sub.shop.io,2","C,invalid,3"]domain = "@shop.io"return = ["A,a@shop.io,1"]

The optional leading @ is ignored. A subdomain is not an exact match, and the malformed email is ignored.

Example 3

contacts = ["A,@example.com,1","B,b@@example.com,2","C,c@example.org,3"]domain = "example.com"return = []

The first email has an empty local part, the second has two @ characters, and the third uses another domain.

Constraints

  • 0 <= contacts.length <= 100000.
  • Every contact string has length at most 500.
  • A well-formed contact row contains exactly two commas; its fields do not contain commas.
  • domain is non-empty after removing one optional leading @ and contains no whitespace, comma, or @.
  • Email local parts and domains are compared without trimming; only domain letter case is ignored.

More Stripe Onsite Interview questions

  • Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Render a Task Tree from CSV RowsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Transaction Rule Expression EvaluatorONSITE INTERVIEW · Seen Oct 2026
  • Evaluate Ordered Action RulesPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • WebSocket Load Balancer — Parts 1–5OA · ONSITE INTERVIEW · Seen Sep 2026
  • Rule-Driven Transaction Fraud DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Account Balance Manager Part 3 - Platform CoverageONSITE INTERVIEW · Seen May 2026
  • Account Balance Manager Part 2 - Reject OverdraftsONSITE INTERVIEW · Seen May 2026
  • Account Balance Manager Part 1 - Calculate TotalsONSITE INTERVIEW · Seen May 2026

Similar questions at other companies

  • Message Latencies from CSV LogsAmazon · ONSITE INTERVIEW
  • Most Cost-Effective MachineCapital One · ONSITE INTERVIEWCapital One interview questions
  • Flatten a Mixed JSON ListNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Parse and Order Structured LogsCoinbase · ONSITE INTERVIEWCoinbase interview questions
  • Rank Word-Translation Hints from Sentence TranslationsDuolingo · ONSITE INTERVIEWDuolingo interview questions
  • Deep Merge with a Conflict ResolverAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Parse Command-Line TokensSamsara · ONSITE INTERVIEWSamsara interview questions
  • Highest-Ranked University by CountryAgoda · OAAgoda interview questions
  • Large ResponsesPostman · OAPostman interview questions

Interview reports that mention this question

  • Stripe New Grad Coding Patterns, 2026 Guide
  • Stripe New Grad Interview Question Bank: 47 Problems

Stripe interview experiences

  • Stripe New Grad SWE OA and Phone Screen: 2 Experiences
  • Stripe Experienced SWE OA and Onsite Questions: 3 Experiences
  • Stripe SWE Intern Linked Merchants Team Screen: 1 Experience
  • Stripe OA: What It Tests (2026)
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public String[] filterContactsByDomain(String[] contacts, String domain) {
      // write your code here
    }
}
Checking account…