This is a verified interview question from Sap-labs. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Minimum Dominoes to Remove - Sap Labs" covers key patterns like DP.
"A domino is a rectangular tile divided into two square parts. There are between 1 and 6 dots on each of the parts. There is an array A of length 2*N , representing N dominoes. Dominoes are arranged in a line in the order in which they appear in array A. The number of dots on the left and the right parts of the K-th domino are A[ 2*k ] and A[ 2*k+1 ] , respectively. For example, an array A = [2, 4, 1, 1, 3, 4, 6, 2, 4, 1, 6] represents a sequence of five domino tiles: (2, 4), (1, 3), (4, 6), (2, 4), and (1, 6). In a correct domino sequence, each pair of neighboring tiles should have the same number of dots on their adjacent parts. For example, tiles (2, 4) and (4, 6) form a correct domino sequence and tiles (2, 4) and (1, 3) do not. What is the minimum number of domino tiles that must be removed from the sequence so that the remaining tiles form a correct domino sequence? It"
Join thousands of developers practicing for Sap-labs.