This set of problems evaluates algorithmic skills in pattern recognition, state management, and sequence processing, specifically testing pattern-based decision rules on time-series stock data and iterative substring elimination in string processing within the Coding & Algorithms domain.
Given an array of daily stock prices and two pattern arrays: sellPattern and buyPattern, each consisting of 1 (price up) and -1 (price down) representing the required consecutive daily movements that must appear immediately before a sell or buy action respectively. On any day you may execute both a buy and a sell if both patterns match ending that day. Return an integer array shares[0..n-1] where shares[i] is the number of shares held after processing day i. Example: prices = ?, sellPattern = [1,1], buyPattern = [...]; expected output [0,0,1,2,1,0].
——
Given a string s and a fixed set of substrings combos (e.g., {"bc", "ab", "cd"}), repeatedly remove every occurrence of any combo from s until no such substring remains. Return the resulting string.