Company: ZS_4oct
Difficulty: medium
Warehouse of Automobile Factory Problem Description You are working in the warehouse of an automobile company and are required to sell automobile parts in the wholesale market. The parts stand in a row, and you are given two arrays of size N : UniqueId[] , where UniqueId[i] is the unique ID of the i -th automobile part. Profit[] , where Profit[i] is the profit that can be earned by selling the i -th part. A profit may be negative (a loss) or zero. You may sell any selection of the parts, subject to one rule: Note: If two or more consecutive parts in the array UniqueId[] have the same ID, then only the one amongst them with the maximum profit can be sold. In other words, split the row into maximal blocks of adjacent parts that share the same ID. From each block at most one part can be sold. Parts with the same ID that are not adjacent in the array (some part with a different ID stands between them) belong to different blocks and can both be sold. Your task is to return the maximum total