Stable Column Names
Asked at Microsoft· Onsite
Reported by the problem's creator, not verified
A tool exports table schemas repeatedly and must give every column a stable, safe name. You process a sequence of schema snapshots and compute each column's effective name.
Each snapshot is a list of strings: the first item is a table name and the remaining items are that table's current column names, in order. Each table keeps its own independent state across snapshots.
Examples
Example 1
Input: calls =
[["T","a.b","a_b","a_b_1"],["T","a_b"],["T","a_b_1","a.b","A.B"],["U","a_b"]]Output:
[["a_b","a_b_1","a_b_1_1"],["a_b_1"],["a_b_1_1","a_b","A_B_2"],["a_b"]]Explanation: In the first call
a.btakesa_b,a_btakesa_b_1anda_b_1takesa_b_1_1. The second call returns the stored name. In the third callA.Bis a new column:A_BandA_B_1are taken ignoring case, so it getsA_B_2. TableUstarts with empty state.