Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Start free
Wildcard Pattern with Digits
00:00
5 left

Wildcard Pattern with Digits

HardPython

Problem

You are given two strings s1 and s2. The wildcard character is now denoted by a number instead of a '.' - it denotes the number of consecutive wildcard characters that would appear in s1. The number would range from 0-9.

Asked in the onsite coding stage. Part 2 of the same problem. Implement wildcard_match(s1, s2), returning true if the entire pattern s1 matches s2. Letters in s1 match themselves, while each digit matches exactly that many arbitrary characters.

Examples: r2t and rokt return true; r3t and rokt return false; 1111 and rokt return true; r1k1 and rokt return true.

Inputs contain lowercase letters and digits in s1, and lowercase letters in s2.

Constraints

  • 1 <= s1.length <= 1000
  • 0 <= s2.length <= 1000
  • s1 contains only lowercase letters and digits from 0 to 9
  • s2 contains only lowercase letters
  • A digit in s1 represents exactly that many arbitrary characters

Function Signature

def wildcard_match(s1, s2):
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements are in the Question tab.

Sign up free to run or submit. Log in
CodePython 3
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 2
Run your code to see test output here.