layout: posttitle: PHP 计算至少是其他数字两倍的最大数
subtitle: PHP 计算至少是其他数字两倍的最大数
date: 2020-05-27
author: he xiaodong
header-img: img/default-post-bg.jpg
catalog: true
tags:
- Go
- PHP
- LeetCode
- 计算至少是其他数字两倍的最大数
计算Excel表列名称
给定一个正整数,返回它在 Excel 表中相对应的列名称。
例如:
1 -> A2 -> B3 -> C...26 -> Z27 -> AA28 -> AB...
示例 1:
输入: 1输出: "A"
示例 2:
输入: 28输出: "AB"
示例 3:
输入: 701输出: "ZY"
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/excel-sheet-column-title
解题思路
PHP 实现
class Solution {/*** @param Integer $n* @return String*/function convertToTitle($n) {$letter = '';while ($n > 0) {$n--;$letter = chr($n % 26 + 65) . $letter;$n = (int)($n / 26);}return $letter;}}
© 原创文章
