Convert Excel Column Title to Number

Duration: 7 min

This video lesson is available to enrolled students.

Return to /learn/WIPRO-PREPARATION/coeding/coding-questions/coding-question/asset-convert-excel-column-title-to-number after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Quantitative Aptitude: Number System, Percentage, Profit and Loss, Ratio and Proportion (Ratios), Average, Time and Work, Speed Time and Distance, Simple Interest and Compound Interest, Mixture and Alligation, Data Interpretation, Permutation and Combination, Probability, Logarithm, Powers and Exponents (Surds and Indices), Age Problems, Divisibility Rules, Partnership, HCF LCM, Algebra, Pipe and Cistern
  2. Logical Reasoning: Series (Number and Letter Series) (Numerical Relations and Reasoning), Analogy, Coding Decoding, Blood Relations, Directions (Direction Test), Syllogisms, Logical Sequence Of Words, Data Sufficiency, Seating Arrangements, Puzzle Solving (Puzzles), Calendar, Clock, Cubes & Dices, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Data Arrangement
  3. English Language: Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Sentence Correction (Error Correction), Sentence Completion (Fill in the blanks), Vocabulary, Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Active Passive Voice (Voice), Direct and Indirect Speech, Cloze Test (Cloze Passage), Tenses, Subject Verb Agreement (Verb Noun Agreement), Preposition, Articles, Conjunction, Adverb
  4. Written English Test: English Writing Ability
  5. Coding: Coding Questions by Yash Sir, C Programming by Yash Sir, Programming in C++, Java, Python for Placements by Yash Sir
  6. Communication Round: Communication Assessment
  7. DBMS (Technical Interview): Basics of DBMS, ER Diagram, Relational Model & Functional Dependencies, Keys & Integrity Constraints, Normalization (1NF - BCNF), Decomposition Properties & 4NF, File Organization & Indexing, Relational Algebra, Relational Calculus, Transaction Management, Concurrency Control, Database Recovery, ORDBMS, Database Security & Authorization, Query Processing & Optimization, Enhanced Data Models, Big Data Systems, NoSQL, Data Warehousing & Mining
  8. SQL (Technical Interview): SQL
  9. Operating Systems (Technical Interview): Introduction to OS, Process Management, CPU Scheduling, Process Synchronization, Deadlock, Threads & Process Creation, Memory Management, Virtual Memory, Disc Scheduling, File Management, Windows OS, Linux OS, Security, Distributed Systems, Virtual Machines
  10. Computer Networks (Technical Interview): 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, Cloud Computing and IoT, Cyber and Info Security
  11. OOPs (Technical Interview): Object Oriented Programming (OOPS)
  12. HR Interview: MR & HR Interview Preparation
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

  1. 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. 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)'.

  3. 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.

Loading lesson…