首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
字典序排列
[编程题]字典序排列
热度指数:558
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 256M,其他语言512M
算法知识视频讲解
给定一个正整数,按字典序返回 [1,n] 内的正整数。
数据范围:
示例1
输入
5
输出
[1,2,3,4,5]
示例2
输入
10
输出
[1,10,2,3,4,5,6,7,8,9]
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(16)
分享
纠错
提交结果有问题?
7个回答
4篇题解
开通博客
牛客791761168号
发表于 2022-03-31 22:53:56
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param n int整型 # @return int整型一维数组 # class Solution: def orderArray(self , n: int) -> List[int]:
展开全文
姐姐的遮阳伞
发表于 2022-04-06 17:56:32
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return
展开全文
17c89
发表于 2024-04-19 15:47:16
import java.util.*; /** * NC362 字典序排列 * @author d3y1 */ public class Solution { ArrayList<Integer> result = new ArrayList<>();
展开全文
歆辰丶
发表于 2023-04-02 21:47:41
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return i
展开全文
问题信息
字典树
dfs
难度:
7条回答
16收藏
1434浏览
热门推荐
通过挑战的用户
查看代码
牛客63244...
2022-09-14 22:26:23
Secret1...
2022-09-10 19:35:43
宋兵亿
2022-09-08 22:00:09
dhy丶
2022-09-08 15:35:14
hui腾打工人
2022-09-07 18:34:35
相关试题
相似和
字典树
评论
(3)
分支限界法与回溯法的相同点是()
dfs
评论
(4)
来自
360公司2016研发工...
利用回溯法求下列不等式的所有整数解...
dfs
评论
(10)
来自
乐视2017秋招开发工程...
有同事不完成任务,影响力进度,你怎...
业务综合
评论
(1)
你身边有哪些人还没有使用滴滴,你认...
用户研究
评论
(1)
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return int整型ArrayList */ public ArrayList
orderArray (int n) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return int整型vector */ vector
orderArray(int n) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param n int整型 # @return int整型一维数组 # class Solution: def orderArray(self , n ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return int整型一维数组 */ public List
orderArray (int n) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return int整型一维数组 */ function orderArray( n ) { // write code here } module.exports = { orderArray : orderArray };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param n int整型 # @return int整型一维数组 # class Solution: def orderArray(self , n: int) -> List[int]: # write code here
package main //import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return int整型一维数组 */ func orderArray( n int ) []int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return int整型一维数组 * @return int* returnSize 返回数组行数 */ int* orderArray(int n, int* returnSize ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param n int整型 # @return int整型一维数组 # class Solution def orderArray(n) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return int整型一维数组 */ def orderArray(n: Int): Array[Int] = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return int整型一维数组 */ fun orderArray(n: Int): IntArray { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return int整型一维数组 */ public int[] orderArray (int n) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return int整型一维数组 */ export function orderArray(n: number): number[] { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return int整型一维数组 */ func orderArray ( _ n: Int) -> [Int] { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return int整型一维数组 */ pub fn orderArray(&self, n: i32) -> Vec
{ // write code here } }
5
[1,2,3,4,5]
10
[1,10,2,3,4,5,6,7,8,9]