yes yes i forgot to say
when n is 26 we ll get (26)0 ie A0
so wen u encounter 0 u need to borrow one which ll become 26 for the
borrower number from previous number
so it ll become 0Z.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group
@albert, You need to becareful when doing the divide, because there is no
ZERO. (Z -> AA not Z->A0).
here is the code:
public static String ExcelMapIntToStr(int n)
{
StringBuilder sb = new StringBuilder();
while(n>0)
{
sb.append((char)(('A' - 1) + (n-1)%26 + 1));
n = (n-1)/26;
}
return sb
since the problem uses all 26 letters, we could use a number system with
base as 26. 2 operations are -
1) Given number to string - Treat the number as number in base 26.
2) Given string to number.
Credit goes here -
http://geeksforgeeks.org/forum/topic/amazon-interview-question-for-software-engi
Simply L division by 26 gives the answer ...
like decimal to binary conversion thats it
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send emai