leetcode168
public class Solution {
private string Convert(int k)
{
var s = "";
switch (k)
{
case :
s = "A";
break;
case :
s = "B";
break;
case :
s = "C";
break;
case :
s = "D";
break;
case :
s = "E";
break;
case :
s = "F";
break;
case :
s = "G";
break;
case :
s = "H";
break;
case :
s = "I";
break;
case :
s = "J";
break;
case :
s = "K";
break;
case :
s = "L";
break;
case :
s = "M";
break;
case :
s = "N";
break;
case :
s = "O";
break;
case :
s = "P";
break;
case :
s = "Q";
break;
case :
s = "R";
break;
case :
s = "S";
break;
case :
s = "T";
break;
case :
s = "U";
break;
case :
s = "V";
break;
case :
s = "W";
break;
case :
s = "X";
break;
case :
s = "Y";
break;
case :
s = "Z";
break;
}
return s;
}
public string ConvertToTitle(int n)
{
var list = new List<int>();
while (n != )
{
var k = n % ;
list.Add(k);
if (k == )
{
n = n / - ;
}
else
{
n = n / ;
}
}
list.Reverse();
StringBuilder sb = new StringBuilder();
for (int i = ; i < list.Count; i++)
{
var s = Convert(list[i]);
sb.Append(s);
}
return sb.ToString();
}
}
https://leetcode.com/problems/excel-sheet-column-title/#/description
leetcode168的更多相关文章
- [Swift]LeetCode168. Excel表列名称 | Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet. For exa ...
- LeetCode168.Excel表列名称
给定一个正整数,返回它在 Excel 表中相对应的列名称. 例如, 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> ...
- leetcode-168周赛-1297-子串的最大出现次数
题目描述: 自己的提交: class Solution: def maxFreq(self, s: str, maxLetters: int, minSize: int, maxSize: int) ...
- leetcode-168周赛-1298-你能从盒子中获得的最大糖果数
题目描述: 方法一:bfs class Solution: def maxCandies(self, status: List[int], candies: List[int], keys: List ...
- leetcode-168周赛-1295-统计位数为偶数的数字
题目描述: 方法一:O(N) class Solution: def findNumbers(self, nums: List[int]) -> int: ans=0 for num in nu ...
- leetcode-168周赛-1296-划分数字为连续数字的集合
题目描述: 自己的提交: class Solution: def isPossibleDivide(self, nums: List[int], k: int) -> bool: c = col ...
- LeetCode 168. Excel表列名称(Excel Sheet Column Title)
168. Excel表列名称 168. Excel Sheet Column Title 题目描述 给定一个正整数,返回它在 Excel 表中相对应的列名称. LeetCode168. Excel S ...
随机推荐
- 【剑指offer】左旋转字符串,C+实现
原创博文,转载请注明出处! 本题牛客网地址 本题代码的github地址 本系列文章的索引地址 # 题目 # 思路 先局部翻转,后整体翻转.举例:abcdefg先局部翻转为bagfedc,后整体翻转为c ...
- threejs 世界坐标与屏幕坐标相互转换
屏幕坐标转世界坐标: let pX = (screenPoint.x / this.scene.renderer.domElement.clientWidth) * 2 - 1; let pY = - ...
- python笔记-11 rabbitmq
一.理解rabbitmq的基本背景 1.理解消息队列 1.1 普通queue 在前面的博客中所提到的队列,此处均称之为普通队列 简述一下普通队列的一些分类及不足 1.1.1 基本Queue:queue ...
- 开发中常见的ES6语句
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- simulink使用system test测试 (matlab2014a)
simulink中有个工具system test,tools->systemtest->launch system test 打开.打开之后界面是这样的 选择insert->test ...
- UVA11401 Triangle Counting
题意 输入\(n\),输出有多少种方法可以从\(1,2,3,\dots,n\)中选出3个不同的整数,使得以他们为三边长可以组成三角形. \(n \leq 10^6\) 分析 参照刘汝佳的题解. 按最大 ...
- 让nodejs 支持 es6 import
备注: 尽管nodejs 新版本已经支持es6 的好多特性了,但是还是有部分不支持,为了使用,实际上我们有一个 比较强大工具 bable,下面介绍几个比较简单的用法. 1. bable-cli ...
- 7个GIF动图帮你瞬间理解三角函数
7个GIF动图帮你瞬间理解三角函数 蝌蚪五线谱 百家号04-2120:53 图片来源:IMGUR 三角函数是数学中研究三角形的一个分支,专门阐述三角形的角度和对应边的关系. 有趣的是,定义边角关系的三 ...
- DiscuzX 3. 3搭建和学习
Discuz!全局变量$_G详解 http://jingyan.baidu.com/article/cb5d610516048c005c2fe0c8.html UCenter uc_user_synl ...
- ecmall页面空白解决方案(转)
页面空白解决方案: ------------------------------------------------------------------------------------------ ...