首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
字典序第K小
[编程题]字典序第K小
热度指数:564
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 256M,其他语言512M
算法知识视频讲解
给定正整数 n 和 k ,请你找出 [1,n] 内的字典序第 k 小的数。
数据范围:
示例1
输入
5,5
输出
5
示例2
输入
50,4
输出
12
说明
字典序的排列是 [1,10,11,12,13...]
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(23)
分享
纠错
提交结果有问题?
2个回答
1篇题解
开通博客
17c89
发表于 2025-02-28 22:50:25
import java.util.*; /** * NC334 字典序第K小 * @author d3y1 */ public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * *
展开全文
问题信息
字典树
难度:
2条回答
23收藏
1424浏览
热门推荐
通过挑战的用户
查看代码
酋非天
2022-09-12 20:36:35
刻苦的大熊猫在度假
2022-09-12 10:25:55
就,很有意思
2022-09-07 09:09:16
wmymartin
2022-08-31 18:43:39
LL.C
2022-08-31 11:00:36
相关试题
原根
字符串
字典树
评论
(6)
单双难全
字符串
字典树
评论
(3)
相似和
字典树
评论
(3)
在大语言模型中,什么是"Gated...
大模型开发
评论
(1)
关于大模型“上下文窗口”的理解,以...
大模型概念
评论
(1)
字典序第K小
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param k int整型 * @return int整型 */ public int findKth (int n, int k) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param k int整型 * @return int整型 */ int findKth(int n, int k) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param n int整型 # @param k int整型 # @return int整型 # class Solution: def findKth(self , n , k ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param k int整型 * @return int整型 */ public int findKth (int n, int k) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param k int整型 * @return int整型 */ function findKth( n , k ) { // write code here } module.exports = { findKth : findKth };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param n int整型 # @param k int整型 # @return int整型 # class Solution: def findKth(self , n: int, k: int) -> int: # write code here
package main import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param k int整型 * @return int整型 */ func findKth( n int , k int ) int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param k int整型 * @return int整型 */ int findKth(int n, int k ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param n int整型 # @param k int整型 # @return int整型 # class Solution def findKth(n, k) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param k int整型 * @return int整型 */ def findKth(n: Int,k: Int): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param k int整型 * @return int整型 */ fun findKth(n: Int,k: Int): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param k int整型 * @return int整型 */ public int findKth (int n, int k) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param k int整型 * @return int整型 */ export function findKth(n: number, k: number): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param k int整型 * @return int整型 */ func findKth ( _ n: Int, _ k: Int) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param k int整型 * @return int整型 */ pub fn findKth(&self, n: i32, k: i32) -> i32 { // write code here } }
5,5
5
50,4
12