当前位置:网站首页>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 :
边栏推荐
- Thread safety and lock optimization
- 13 `bs_ duixiang. Tag tag ` get a tag object
- 这不会又是一个Go的BUG吧?
- Zhongshanshan: engineers after being blasted will take off | ONEFLOW u
- CODING CD
- Container JVM that has to be picked up
- One article introduces you to the world of kubernetes
- version `ZLIB_ 1.2.9‘ not found (required by /lib64/libpng16.so.16)
- [SPRS J P & RS 2022] small target detection module: a normalized Gaussian Wasserstein distance for tiny object detection
- CTF steganography
猜你喜欢

【小程序】编译预览小程序时,出现-80063错误提示

Cvpr2022 𞓜 thin domain adaptation

Niu Xuechang's anniversary celebration: software promotion, limited time and free registration code!

WinSCP和PuTTY的安装和使用

同行评议论文怎么写

Perhaps the greatest romance of programmers is to commemorate their dead mother with a software
![[shutter] how to use shutter packages and plug-ins](/img/a6/e494dcdb2d3830b6d6c24d0ee05af2.png)
[shutter] how to use shutter packages and plug-ins

Handwritten digit recognition using SVM, Bayesian classification, binary tree and CNN

Zhongshanshan: engineers after being blasted will take off | ONEFLOW u
Shengdun technology joined dragon lizard community to build a new open source ecosystem
随机推荐
"Ai+ education" and "Ai education": one for education and the other for Education
How to quickly convert stock code into int in quantitative trading?
Vs2022 save formatting plug-in
Icml'22 | progcl: rethinking difficult sample mining in graph contrast learning
股票网上开户安全吗?需要满足什么条件?
Kubernetes' ci/cd practice based on Jenkins spinnaker - adding product image scanning
实时计算框架:Flink集群搭建与运行机制
实时计算框架:Spark集群搭建与入门案例
[applet] when compiling the preview applet, a -80063 error prompt appears
GNN上分利器!与其绞尽脑汁炼丹,不如给你的GNN撒点trick吧
985 Android programmers won the oral offer of Alibaba P6 in 40 days. After the successful interview, they sorted out these interview ideas
Shardingsphere-proxy-5.0.0 implementation of capacity range partition (V)
November 20, 2021: the start and end times of a movie can be listed in a small array
ShardingSphere-proxy-5.0.0容量范围分片的实现(五)
Real time preview of RTSP video based on webrtc
NJS triggers system command operation
Zhongshanshan: engineers after being blasted will take off | ONEFLOW u
Data management: business data cleaning and implementation scheme
【ICPR 2021】遥感图中的密集小目标检测:Tiny Object Detection in Aerial Images
[CVPR 2020] conference version: a physics based noise formation model for extreme low light raw denoising