You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
10 test cases are passed but n=5473578 is giving one character wrong.
soln..
class Solution{
public:
void clm_name(long long int n,string&ans,vector<char>&alpha){
if(n<=26){
ans.push_back(alpha[n-1]);
return;
}
long long clm_no=n/26;
int row_no=n%26;
clm_name(clm_no,ans,alpha);
ans.push_back(alpha[row_no-1]);
if(row_no==0)ans.push_back('Z');
}
string colName (long long int n)
{ vector<char>alpha(26);
int d=65;
for(int i=0;i<26;i++)
alpha[i]=d+i;
string ans;
clm_name(n,ans,alpha);
return ans;
}
};
The text was updated successfully, but these errors were encountered:
class Solution{ public: void clm_name(long long int n,string&ans,vector<char>&alpha){ if(n<=26){ ans.push_back(alpha[n]); return; } long long clm_no=n/26; int row_no=n%26; clm_name(clm_no-1,ans,alpha); ans.push_back(alpha[row_no]); //if(row_no==0)ans.push_back('Z'); } string colName (long long int n) { vector<char>alpha(26); int d=65; for(int i=0;i<26;i++) alpha[i]=d+i; string ans; clm_name(n-1,ans,alpha); return ans; } };
now it's working but why we are subtracting -1 from the n bhaiya??
10
test cases are passed but n=5473578 is giving one character wrong.soln..
The text was updated successfully, but these errors were encountered: