Stable Column Names

Asked at Microsoft· Onsite

Reported by the problem's creator, not verified

Import another question

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

  1. 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.b takes a_b, a_b takes a_b_1 and a_b_1 takes a_b_1_1. The second call returns the stored name. In the third call A.B is a new column: A_B and A_B_1 are taken ignoring case, so it gets A_B_2. Table U starts with empty state.

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.