Hidden Artifacts
Reported by candidates from IMC's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt at IMC's Hidden Artifacts, reported in October 2020, is parsing. Rows can be two digits, columns are letters, and the input is one messy string. Candidates burn their time on indexing and miss the easy part. The logic is a hash set and a counting loop over rectangles. Searched cells go in a set, each artifact gets expanded cell by cell, and you compare hits to area. If you blank on the parsing mid-assessment, StealthCoder runs invisibly as a safety net and hands you the solution while you keep typing.
The problem
An archaeological site is represented by an n-by-n grid. Rows are numbered from 1 through n, and columns are labeled from A through the nth uppercase letter. A cell is written as its row followed by its column, such as 9C. Each hidden artifact occupies an axis-aligned rectangular group of cells. Artifacts do not overlap, and each artifact has area at most 4. The string artifacts contains comma-separated artifact descriptors. Each descriptor has the form topLeft bottomRight. The string searched contains distinct searched cells separated by spaces. An artifact is fully reconstructed when every cell it occupies has been searched. It is partially found when at least one, but not all, of its cells have been searched. Return an integer array [fullyReconstructed, partiallyFound]. Function findHiddenArtifacts(n: int, artifacts: String, searched: String) → int[] Examples Example 1 n = 4 artifacts = "1B 2C, 2D 4D" searched = "2B 2D 3D 4D 4A" return = [1,1] The vertical artifact from 2D through 4D is fully reconstructed. The 2-by-2 artifact has only cell 2B found, so it is partial. Example 2 n = 3 artifacts = "1A 1B, 2C 2C" searched = "1B" return = [0,1] Only one cell of the first artifact has been found, and the single-cell artifact at 2C has not been found. Constraints 1 <= n <= 26 Every artifact descriptor names the valid top-left and bottom-right cells of an axis-aligned rectangle. Each artifact occupies at most 4 cells. No grid cell belongs to more than one artifact. Every cell in searched is valid and appears at most once. Artifact descriptors and searched cells may appear in any order.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that artifacts hold at most 4 cells, so brute force is cheap. Put every searched cell in a hash set as a string like 2B. Split artifacts on commas, then split each descriptor on a space. For each corner, the row is every character except the last, and the column is the last character. Loop rows from top to bottom and columns from left to right, count how many cells sit in the set, and track the total area. If hits equal area, increment fully reconstructed. If hits are above zero but below area, increment partially found. The classic pitfall is reading the row as a single digit, so 10A breaks. Another is trimming whitespace badly after the comma split. If the parsing logic slips under pressure, StealthCoder is the hedge on the live OA, giving you a clean reference while the proctor sees nothing.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Hidden Artifacts cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass IMC's OA.
IMC reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Hidden Artifacts FAQ
How hard is Hidden Artifacts really?+
Easy on logic, annoying on parsing. The algorithm is a set lookup and a double loop over tiny rectangles. Most failed attempts come from string handling, like multi-digit rows or stray spaces after commas, not from the counting itself.
What's the trick to solve it fast?+
Store searched cells in a hash set of strings. For each artifact, enumerate every cell in its rectangle and count how many are in the set. Compare the hit count to the area. Full match is reconstructed, anything between zero and full is partial.
How do I parse cells like 10C correctly?+
Take the last character as the column and everything before it as the row number. Convert the row with an integer parse and the column with its character offset from A. Never assume the row is one digit, since n goes up to 26.
Does the 4-cell area limit matter?+
It means you don't need any clever geometry or grid-wide scanning. Enumerating each artifact is constant work. Total time is linear in the number of artifacts plus searched cells, which is more than fast enough.
How do I prepare in 48 hours for this kind of OA?+
Practice string parsing with hash sets and grid coordinates. Write this one from scratch twice, with edge cases like single-cell artifacts, unordered input, and two-digit rows. That covers the whole difficulty of the problem.