Question: given an array of colors A = [a1, a2, . . . , an] drawn from k colors {c1, c2, . . . , ck},
given an array of colors A = [a1, a2, . . . , an] drawn from k colors {c1, c2, . . . , ck}, so A is a subset of k, and k is a constant. We wish to compute k indices i1, i2, . . . , ik, for each element ai , such that ij is the index of the closest element to the left of ai whose color is cj . If no such element exists, then set ij = 0. Write pseudocode for solving this problem
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
