当前位置:网站首页>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 :
边栏推荐
- The best Base64 encoding and decoding tutorial in the whole network, with 6 examples!
- Apple iphone14 is equipped with Beidou navigation system. What are the advantages of Beidou vs GPS?
- VS2022保存格式化插件
- 用一个软件纪念自己故去的母亲,这或许才是程序员最大的浪漫吧
- 7 tips for preventing DDoS Attacks
- version `ZLIB_ 1.2.9‘ not found (required by /lib64/libpng16.so.16)
- ctfhub---SSRF
- What is memory out of order access?
- 【CVPR 2020 Oral】极低光去噪论文:A Physics-based Noise Formation Model for Extreme Low-light Raw Denoising
- ICML'22 | ProGCL: 重新思考图对比学习中的难样本挖掘
猜你喜欢

GNN upper edge distributor! Instead of trying to refine pills, you might as well give your GNN some tricks

数据管理:业务数据清洗,落地实现方案

How to write peer-reviewed papers

WinSCP和PuTTY的安装和使用

Shardingsphere-proxy-5.0.0 implementation of capacity range partition (V)

Pad User Guide
![[applet] realize the effect of double column commodities](/img/e3/b72955c1ae67ec124520ca46c22773.png)
[applet] realize the effect of double column commodities

【CVPR 2022】高分辨率小目标检测:Cascaded Sparse Query for Accelerating High-Resolution Smal Object Detection

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

阿里巴巴面试题:多线程相关
随机推荐
Cvpr2022 𞓜 thin domain adaptation
numpy.linalg.lstsq(a,b,rcond=-1)解析
一次 MySQL 误操作导致的事故,「高可用」都顶不住了!
An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!
The dispute between traditional IT development and low code development is heated, and the technical development rules may be restructured?
Law / principle / rule / rule / theorem / axiom / essence / Law
[technical grass planting] use webhook to automatically deploy my blogs on multiple sites in Tencent cloud
"Ai+ education" and "Ai education": one for education and the other for Education
Arm learning (7) symbol table and debugging
机器学习中 TP FP TN FN的概念
CVPR2022 | 可精简域适应
13 `bs_duixiang.tag标签`得到一个tag对象
ICML'22 | ProGCL: 重新思考图对比学习中的难样本挖掘
【小程序】编译预览小程序时,出现-80063错误提示
Echo framework: implementing distributed log tracing
Vs2022 save formatting plug-in
[redis advanced ziplist] if someone asks you what is a compressed list? Please dump this article directly to him.
Map data types in golang
Grab startup logcat
Real time preview of RTSP video based on webrtc