Excel Sheet Column Title | Made it simple | Dry Run | Leetcode-168 | Meta | Microsoft | Explanation

preview_player
Показать описание
This is the 12th Video on our Strings Playlist.
In this video we will try to solve a very good and famous Maths problem "Excel Sheet Column Title" (Leetcode-168)

I have also explained the Maths part and also Time Complexity in this video.
We will simply treat it like normal numbers and solve it like a cake walk.

We will do live coding after explanation and see if we are able to pass all the test cases.

Problem Name : Excel Sheet Column Title
Company Tags : Facebook, Zenefits, Microsoft

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips
#interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook
Рекомендации по теме
Комментарии
Автор

JAVA CODE

class Solution {

public String convertToTitle(int columnNumber) {
StringBuilder result = new StringBuilder();

while(columnNumber > 0) {
columnNumber--;
int remain = columnNumber%26;


result.append((char)((remain + 'A')));
columnNumber = (columnNumber) / 26;
}

// Reverse it, as we appended characters in reverse order.
return result.reverse().toString();
}
}

codestorywithMIK
Автор

I try too much but unable to solve and try to understand why -1 in columnNumber but no one explian well with institute in LC solution, then i realise now ki ab ek hi insaan samjaa sekta hai codestorywithmik and i satisfied with core institute of -1 in columnNumber thanku bhaiya

ankitsingh
Автор

Simple, Clean, Crystal Clear. my one stop solution to any problem

wearevacationuncoverers
Автор

Thanks for the great explanation bhaiya 😊. I already did this question by my own.

GeniusOG
Автор

The explanation is so crisp. Just loved it. Far better than already available videos on this problem

AlishaKhan-wwio
Автор

One of the best explanation man! You have something of a gift for this, or maybe it was hardwork or, better both.
You just earned a subscriber mate!

atharvpal
Автор

the edge case was tricky to handle. you explained it really well

shloksuman
Автор

Man you always makes things so simple. Loved the explanation

souravjoshi
Автор

As usual, your explanation was excellent. 👍👌😊

souvikmukherjee
Автор

Python code :

class Solution:
def convertToTitle(self, columnNumber: int) -> str:
ans = ''

while columnNumber :
columnNumber -=1
columnNumber, rem = columnNumber // 26, columnNumber % 26
ans = chr(rem + ord('A')) + ans

return ans

ishwarkoki
Автор

bro your teaching style is so good, you should also make video solution of gfg potd

prasantsethi
Автор

if you want to save some time dont reverse the string just add it in reverse order instead, c++ code


string convertToTitle(int columnNumber) {
string res = "";
int m = columnNumber;

while(m) {
m -=1;
int rem = m%26;
char ch = 'A' + rem;
res = ch + res;
m /= 26;
}

return res;
}

hi-tkhu
Автор

Public class solution {
Public string convert To Title(int column Number){
String Builder remain=new string Builder ();
while (column Number >0){
remain. insert (0, (char)('A'+(column Number-1)%26));
column Number =(column Number-1)/26;
}
return remain. to string ();
}
};
Thanks 🎉❤

dayashankarlakhotia
Автор

Bro can you explain the concept of digit dp .I want to learn that concept because some of hard problem come with digit dp solution .and i watched lot of videos on this but not anyone explain well so can you do this ?.

CodeBoost
Автор

My JAVA code:

class Solution {
public String convertToTitle(int columnNumber) {
String res = "";
while(columnNumber > 0) {
int rem = columnNumber % 26;
if(rem == 0) rem = 26;
res = String.valueOf((char)(rem + 64)) + res;
columnNumber = (columnNumber - rem) / 26;
}
return res;
}
}

ravitejasriram
Автор

columnNum-- ke alwaa %27 will do the job ?

ManojKrVerma-vwdx
Автор

Checkout my java code

class Solution {
public String convertToTitle(int columnNumber) {
char[] ch = new char[26]; // making one array which will store all characters
char x = 'A';
for(int i=0;i<ch.length;i++){
ch[i] = x;
x++;
}

StringBuilder sb = new StringBuilder();

while(columnNumber>0){
if(columnNumber>26){ //if num is greater than 26 then only perform the operation
int rem = columnNumber%26;
if(rem==0){ // if rem is zero that means it is multiple of 26 i.e char is 'Z' o make rem to 26 and decrement the num by one.
rem = 26;
columnNumber--;
}
sb.append(ch[rem-1]);
columnNumber /= 26;
}
else{ // if num is less than 27 then just add it into string

break;
}
}
sb.reverse();
return sb.toString();
}
}

sahilnikam
Автор

Can anybody please explain the counter-- step, it seems very unintuitive to me

RahulGuptaa
Автор

Bas 1 base system ko convert karna nahi aa raha tha. Interview mein ghanta khud se intuition aayega ki har iteration par columnNumber-- karna hai.

cheapmoves
Автор

Aapne caption mein correction toh likh diya par usme aapne 66 hi likha hai

cacklouncle