Algorithm · Ebay · Easy
Problem: Validate US Phone Numbers with a Regular Expression You are given a string s. Your task is to check whether it represents a valid US phone number. A valid number must contain exactly 10 digits (excluding a leading country code 1). It can appear in any of the following formats: Pure digits: XXXXXXXXXX Hyphen-separated: XXX-XXX-XXXX Space-separated: XXX XXX XXXX An area code enclosed in parentheses: (XXX)XXX-XXXX (XXX) XXX-XXXX (XXX)XXX XXXX Requirements: Return true…
Checking your access…