Company: Ethos_life_25dec
Difficulty: medium
Artifact Collector's Dilemma Problem Description You are a collector exploring a long row of artifact stalls at an ancient market. Each stall contains a specific type of artifact, represented as an integer in an array. You have two storage compartments, and each compartment can store only one type of artifact. However, there is no limit on how many artifacts each compartment can hold. Starting from any stall of your choice, you must collect exactly one artifact per stall while moving only to the right. The collected artifacts must fit into one of your two compartments. The moment you reach a stall displaying an artifact that does not match either of the two types already in your storage compartments, you must stop collecting. Your task is to determine the maximum number of artifacts you can collect under these conditions. Examples Example 1: Input: artifacts = [1,2,1] Output: 3 Explanation: You can collect from all three stalls because they only contain two types of artifacts (1 and 2)