You have several colorful disks of various sizes. You would like to build a pyramid of them by putting disks atop each other and using each disk exactly once. You are only allowed to put a disk of radius R1 atop a disk of radius R2 if R2 >= R1. For each pair of adjacent disks in the pyramid, the upper disk must be completely inside the lower disk when viewed from above. This means the lower disk will only be visible if it has a strictly larger radius than the upper disk.
You must build the pyramid in such a way that all visible disks have the same color when viewed from above. This color is called the color of the pyramid.
You are given a String[] disks, each element of which describes a single disk and is formatted as "color radius" (quotes for clarity). Return a String[] containing all possible colors of the pyramid in alphabetical order. If no pyramid can be built according to the rules, return an empty String[].
|