Convert Excel Column Title to Number
Duration: 7 min
This video lesson is available to enrolled students.
Inside: a video lesson and guided study material.
Module outline
- English Comprehension/Verbal Ability: Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions) Vocabulary Sentence Correction (Error Correction) Sentence Completion (Fill in the blanks) Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing) Subject Verb Agreement (Verb Noun Agreement) Tenses Verb Articles Preposition Conjunction Pronoun Noun Adjectives Adverb Modals Cloze Test (Cloze Passage) Active Passive Voice (Voice) Direct and Indirect Speech Sentence Construction
- Logical Ability: Coding Decoding Directions (Direction Test) Analogy Inequality Data Sufficiency Series (Number and Letter Series) (Numerical Relations and Reasoning) Syllogisms Seating Arrangements Puzzle Solving (Puzzles) Blood Relations Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning) Ranking, Order and Sequence Logical Sequence Of Words Data Arrangement Venn Diagram Calendar Clock
- Quantitative Ability: Logarithm Permutation and Combination Probability Profit and Loss Speed Time and Distance Mixture and Alligation Partnership Simple Interest and Compound Interest Percentage Ratio and Proportion (Ratios) Average Time and Work Pipe and Cistern Number System Divisibility Rules HCF LCM Algebra Powers and Exponents (Surds and Indices) Mensuration and Geometry Age Problems Data Interpretation Sequence and Series (Series)
- Basic Analytical Ability: Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning) Analytical Reasoning (Counting Figures Reasoning) Cubes & Dices Selection Decision Table (Decision Making)
- Computer Programming: Pseudo Codes Coding Questions by Yash Sir C Programming by Yash Sir Programming in C++ Java Python for Placements by Yash Sir
- DBMS (Computer Science): Basics of DBMS ER Diagram Relational Model & Functional Dependencies Keys & Integrity Constraints Normalization (1NF - BCNF) Transaction Management Concurrency Control Database Security & Authorization
- SQL (Computer Science): SQL
- OS (Computer Science): Introduction to OS Process Management CPU Scheduling Deadlock Process Synchronization Threads & Process Creation Memory Management Virtual Memory File Management
- Computer Networks (Computer Science): Introduction to CN Data Communication DLL: Access Control DLL: Flow Control DLL: Error Control DLL: Framing Data Link Layer - Ethernet Net Layer: IPv4 & Proto Net Layer: IP Addressing Net Layer:Routing Protocol Transport Layer Services TL: Congestion & UDP Application Layer Hardware basics Network Security
- Data Structures (Computer Science): Introduction to DS Array Stack Queue Linked List Tree Graphs Hashing
- OOPs (Computer Science): Object Oriented Programming (OOPS)
- Software Engineering (Computer Science): Fundamentals of Software Engineering Software Requirements and Quality Assurance Software Design, Estimation and Metrics Software Testing Software Maintenance and Configuration Management
- SVAR Conversational - Spoken English: Communication Assessment
- HR Interview: MR & HR Interview Preparation
- Coding Practice Questions: Coding Questions Bank
AI summary & chapters
AI Summary
An AI-generated summary of this video lecture.
This educational video from Knowledge Gate provides a comprehensive tutorial on solving a programming problem related to converting an Excel column title to its corresponding column number. The lecture begins by defining the problem: given a string representing an Excel column title (e.g., 'A', 'AA', 'AAA'), find the integer that represents that column. The core of the video is a step-by-step derivation of the algorithm, which is based on a base-26 number system where 'A' represents 1, 'B' represents 2, and so on, up to 'Z' representing 26. The instructor uses a chalkboard to demonstrate the mathematical logic, showing that for a string like 'AA', the calculation is (1 * 26) + 1 = 27. This is generalized into a formula: result = 26 * result + (s[i] - 'A' + 1). The video then transitions to a code implementation in C, showing a function `titleToNumber` that iterates through the string, applying this formula to build the final column number. The lesson is reinforced with multiple worked examples, including the conversion of 'A' to 1, 'AA' to 27, and 'AAC' to 705, which are shown on the board and in the code.
Chapters
0:00 – 2:00 00:00-02:00
The video opens with the Knowledge Gate logo, followed by a slide that introduces the problem. The problem statement is displayed on a whiteboard, which reads: 'Given a string S that represents column title of an Excel sheet, find the number that represents that column. In excel A column is number 1, AA is 27 and so on.' The constraints are listed as 1 ≤ |S| ≤ 7. The input is a single line containing string S, and the output is the column number. An example is provided: Input 'A' outputs 1, and Input 'AA' outputs 27. The instructor, Yash Jain Sir, is visible in a small window, and the video is marked as a copyright of Knowledge Gate Eduventures.
2:00 – 5:00 02:00-05:00
The instructor explains the pattern of Excel column titles, which is a base-26 system. He writes on the chalkboard that column 1 is 'A', column 2 is 'B', ..., column 26 is 'Z', column 27 is 'AA', and so on. He provides a table of examples, showing that 26 maps to 'Z', 51 to 'AY', 52 to 'AZ', 80 to 'CB', 676 to 'ZZ', and 705 to 'AAC'. He then begins to derive the formula for the conversion, writing 'Z -> 26' and 'AA -> 27'. He explains that the first 'A' in 'AA' is in the 26's place, so the calculation is (1 * 26) + 1 = 27. He continues to break down the logic for 'AAC', showing that it is (1 * 26^2) + (1 * 26^1) + (3 * 26^0) = 676 + 26 + 3 = 705. He emphasizes that the formula is 'result = 26 * result + (s[i] - 'A' + 1)'.
5:00 – 6:41 05:00-06:41
The video transitions to a code implementation. A code editor window displays a C function `int titleToNumber(char s[])`. The function initializes an integer `result` to 0. A for loop iterates through each character of the string `s`. Inside the loop, the formula `result = result * 26 + s[i] - 'A' + 1;` is applied. The instructor explains that this formula is derived from the base-26 logic. He then shows the function returning the final `result`. The video concludes by revisiting the examples on the board, confirming that the code correctly handles inputs like 'A' (output 1) and 'AA' (output 27), reinforcing the connection between the mathematical concept and its programming implementation.
The video presents a clear, structured lesson on a classic programming problem. It effectively bridges the gap between a real-world application (Excel column naming) and its underlying mathematical algorithm. The teaching progression moves logically from problem definition to conceptual understanding (base-26 system) to algorithmic derivation (the formula) and finally to practical implementation (the C code). The use of a chalkboard for step-by-step calculations and a code editor for the final solution provides a comprehensive learning experience, making the abstract concept of number systems tangible for students.

