当前位置:网站首页>2021-11-18: given a length len, it indicates how many bits there are in total. All characters
2021-11-18: given a length len, it indicates how many bits there are in total. All characters
2022-06-24 01:19:00 【Fuda scaffold constructor's daily question】
2021-11-18: Given a length len, How many people are there . All characters are lowercase (a~z), Can generate a length of 1, The length is 2, The length is 3... The length is len All strings of . If you sort all strings in dictionary order , Each string has a location . Given a string str, Given len, Please return str Is the number of in the total sequence . such as len = 4, The first few strings in the dictionary order are :a aa aaa aaaa aaab ... aaaz ... azzz b ba baa baaa ... bzzz c ....a Is the... In this sequence 1 individual ,bzzz Is the... In this sequence 36558 individual .
answer 2021-11-18:
cdb, Total length is 7, Excuse me, cdb It's the number one ?
first place c :
With a start , The remaining length is (0~6) There are several possibilities
+
With b start , The remaining length is (0~6) There are several possibilities
+
With c start , The remaining length is (0) There are several possibilities
Second d :
+
With ca In the beginning , The remaining length is (0~5) There are several possibilities
+
With cb In the beginning , The remaining length is (0~5) There are several possibilities
+
With cc In the beginning , The remaining length is (0~5) There are several possibilities
+
With cd In the beginning , The remaining length is (0) There are several possibilities
Third b
+
With cda In the beginning , The remaining length is (0~4) There are several possibilities
+
With cdb In the beginning , The remaining length is (0) There are several possibilities .
The code to use golang To write . The code is as follows :
package main
import "fmt"
func main() {
s := "c"
len0 := 2
ret := kth(s, len0)
fmt.Println(ret)
}
func kth(s string, len0 int) int {
if len(s) == 0 || len(s) > len0 {
return -1
}
num := []byte(s)
ans := 0
for i, rest := 0, len0-1; i < len(num); i, rest = i+1, rest-1 {
ans += int(num[i]-'a')*f(rest) + 1
}
return ans
}
// Whatever it starts with , The remaining length is (0~len) There are several possibilities
func f(len0 int) int {
ans := 1
for i, base := 1, 26; i <= len0; i, base = i+1, base*26 {
ans += base
}
return ans
}The results are as follows :
边栏推荐
- Arm learning (7) symbol table and debugging
- How to view kubernetes API traffic by grabbing packets
- What is memory out of order access?
- version `ZLIB_ 1.2.9‘ not found (required by /lib64/libpng16.so.16)
- numpy.linalg.lstsq(a,b,rcond=-1)解析
- [OSG] OSG development (04) - create multiple scene views
- 数据管理:业务数据清洗,落地实现方案
- Why traifik ingress?
- Use recursion to form a multi-level directory tree structure, with possibly the most detailed notes of the whole network.
- CVPR2022 | 可精简域适应
猜你喜欢
![[shutter] how to use shutter packages and plug-ins](/img/a6/e494dcdb2d3830b6d6c24d0ee05af2.png)
[shutter] how to use shutter packages and plug-ins

WinSCP和PuTTY的安装和使用

Cvpr2022 𞓜 thin domain adaptation

An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!

ShardingSphere-proxy-5.0.0容量范围分片的实现(五)

LMS Virtual. Derivation method of lab acoustic simulation results

【Redis进阶之ZipList】如果再有人问你什么是压缩列表?请把这篇文章直接甩给他。

LSF打开Job idle information以看job的cpu time/elapse time使用情况
![[redis advanced ziplist] if someone asks you what is a compressed list? Please dump this article directly to him.](/img/3f/988ed31a3f1cdc92deed121ed8d4ec.png)
[redis advanced ziplist] if someone asks you what is a compressed list? Please dump this article directly to him.

一次 MySQL 误操作导致的事故,「高可用」都顶不住了!
随机推荐
【Redis进阶之ZipList】如果再有人问你什么是压缩列表?请把这篇文章直接甩给他。
Arm learning (7) symbol table and debugging
【CVPR 2020 Oral】极低光去噪论文:A Physics-based Noise Formation Model for Extreme Low-light Raw Denoising
Real time preview of RTSP video based on webrtc
13 `bs_duixiang.tag标签`得到一个tag对象
Relationship between continuous testing and quality assurance
实时计算框架:Spark集群搭建与入门案例
应用配置管理,基础原理分析
Open source model library of flying propeller industry: accelerating the development and application of enterprise AI tasks
Kubernetes' ci/cd practice based on Jenkins spinnaker - adding product image scanning
Salesforce batch apex batch processing (I)
How to improve program performance
杂乱的知识点
Pad User Guide
Echo framework: implementing distributed log tracing
[applet] realize the effect of double column commodities
股票网上开户安全吗?需要满足什么条件?
Everything I see is the category of my precise positioning! Open source of a new method for saliency map visualization
Echo framework: automatically add requestid
Real time computing framework: Flink cluster construction and operation mechanism