Company: DevRev
Difficulty: medium
Smallest Sub-chain with Golden Elements Problem Description As space explorers, we research on different soil samples and extract chain of elements from them. There is a specific set of elements known as Golden Elements. Write a function that finds the smallest sub-chain that includes all the golden elements. If no such sub-chain exists containing all the golden elements, return an empty sub chain. Examples Example 1: Input: chain = ["O", "C", "Ra", "Li", "Na"], elements = ["Li", "C"] Output: ["C", "Ra", "Li"] Explanation: The smallest sub-chain that contains both "Li" and "C" is `["C", "Ra", "Li"]`. Constraints Execution time limit: 1 second (cpp) Memory limit: 1 GB Input: `array.string chain` Chain of elements we search in Constraint: `0 Input: `array.string elements` Elements we want to find Elements in this array will be unique Constraint: `0 Output: `array.string` The smallest chain that has all the elements inside