Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
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
Get started
Artifact Grid Challenge
00:00
5 left

Artifact Grid Challenge

MediumPython

Problem

Find hidden artifacts: given an N x N grid, a string of artifact rectangles (each at most 4 cells, given by top-left and bottom-right cells like '1B 2C') and a string of searched cells, return how many artifacts were fully found and how many were partially found.

The question was asked in the Online assessment (HackerRank) stage. The artifact string uses comma-separated rectangles, and each rectangle contains two space-separated cells. The searched string contains space-separated cells.

Function: count_artifacts(n, artifacts, searched)

Return [fully_found, partially_found]. An artifact is fully found when every cell was searched, and partially found when at least one but not every cell was searched.

Constraints

  • 1 <= n <= 26
  • 1 <= row <= n
  • Columns are uppercase letters from A through the nth column
  • Each artifact rectangle contains at most 4 cells
  • Artifact rectangles are comma-separated
  • Searched cells are whitespace-separated
  • Return counts in the order [fully_found, partially_found]

Function Signature

def count_artifacts(n, artifacts, searched):
Interviewer

Your question is Artifact Grid Challenge. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.