Little John does a lot of programming, and is therefore very strange. Recently, he started talking with some geometrical figures. Squares are his favorite ones, and he gives names to them. Yes, it is very strange, but don't forget that John is a programmer!
John has drawn many squares on a big sheet of paper and each square has its own name. Now John is looking for a sequence of k squares such that each square except the first one lies inside the previous square in the sequence.
One square lies inside another one if all its points are inside the bigger square, possibly on a boundary.
You are given String[]s x, y, lengths and names, and an int k. For each String[], concatenate all its elements to produce a single string. The concatenated versions of x, y and lengths contain single space separated lists of integers, where the i-th integers represent the x-coordinate and y-coordinate of the bottom left corner and side length, respectively, of the i-th square. The concatenated version of names contains a single space separated list of strings, where the i-th string represents the name of the i-th square.
Return a String[] containing exactly k elements - the names of the squares in the sequence. If there are multiple such sequences, return the one among them that comes first lexicographically. If there is no such sequence, return an empty String[].
|