Company: Intuit_7aug
Difficulty: medium
One-hot Encoding A data set is stored as a plain table of N rows and M columns. Every cell holds a short alphanumeric token, and the cells of a row are written on one line separated by commas. The last column of the table is a categorical column: its cells are labels drawn from a small set of possible values. The remaining M - 1 columns are identifier columns that simply describe the row. Your task is to replace the categorical column with its one-hot encoding . Let the distinct values that appear in the last column be listed in ascending lexicographic order as v[0] < v[1] < ... < v[K-1] . The encoded table has M - 1 + K columns: the first M - 1 identifier columns are copied unchanged, and for each j from 0 to K - 1 , a new column that holds 1 on the rows whose categorical value equals v[j] and 0 on every other row. The rows keep their original order. Input Format The first line contains an integer N — the number of rows. The second line contains an integer M — the number of c