Back to problems

Spreadsheet column label to number

Algorithm · Microsoft · Easy

Spreadsheet columns use an alphabetic naming sequence: after Z the names continue with AA, then AB, and eventually AZ, BA, and so on. In this scheme the first column is A, which has value 1. Given a non-empty string col containing only uppercase English letters, compute the positive integer that identifies that column. Return that integer. Example 1: Explanation: D is the fourth letter, so it corresponds to column 4. Example 2: Explanation: A contributes $$1 \times 26$$ and…

Checking your access…