28/180: GeeksForGeeks: Find excel column names from given column number

Input              Output
26 Z
51 AY
52 AZ
80 CB
676 YZ
702 ZZ
705 AAC
public class ExcelColumnNames{
private static void main printString(int colNo){
Stringbuilder colName = new Stringbuilder();
while(columnNo > 0){
int rem = colNo % 26;
if(rem == 0){
colName.append('Z');
colNo = (colNo/26) -1;
}else{
colName.append((char)((rem-1)+'A'));
colNo = colNo/26;
}
}
System.out.println(colName.reverse());
}

--

--

--

I am Indian by birth, Punjabi by destiny. Humanity is my religion. Love to eat, travel, read books and my million dreams keep me alive.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to use Dave McClure’s Pirate metrics to direct your product development process?

Best New Word Game App of 2020

C Programming Common Errors

In the loop

4 SQL Filtering Concepts to improve your Data Wrangling Game

Variables in Scala

Translation Unit

Shadow Effect| Xamarin.Forms | Xamarin Community Toolkit

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Navneet Ojha

Navneet Ojha

I am Indian by birth, Punjabi by destiny. Humanity is my religion. Love to eat, travel, read books and my million dreams keep me alive.

More from Medium

Huffman coding | Greedy Algorithm

Striver Sheet Day 06 — Linked List

Guide To Dynamic Programming 👨‍💻

Build Array from Permutation — Day 103(Python)