字典序排数-中等
2025-4-20
| 2025-4-20
Words 187Read Time 1 min
type
status
date
slug
summary
tags
category
icon
password

题目:

给你一个整数 n ,按字典序返回范围 [1, n] 内所有整数。
你必须设计一个时间复杂度为 O(n) 且使用 O(1) 额外空间的算法。
来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/SNJvJP 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
示例 1:
示例 2:
提示:
  • 1 <= n <= 5 * 104

思路:

  • TreeSet是字典序

代码:

结果:

notion image
image-20220418095451995
字符串中的单词数子数组最大平均数丨
Loading...