goden1611

package
v0.0.0-...-b071cee Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2023 License: GPL-3.0 Imports: 0 Imported by: 0

README

面试题 16.11.跳水板

1. 题目描述

你正在使用一堆木板建造跳水板。有两种类型的木板,其中长度较短的木板长度为 shorter ,长度较长的木板长度为 longer 。你必须正好使用 k 块木板。编写一个方法,生成跳水板所有可能的长度。

返回的长度需要从小到大排列。

示例 1

输入:
shorter = 1
longer = 2
k = 3
输出: [3,4,5,6]
解释:
可以使用 3 次 shorter,得到结果 3;使用 2 次 shorter 和 1 次 longer,得到结果 4 。以此类推,得到最终结果。

提示:

  • 0 < shorter <= longer
  • 0 <= k <= 100000

标签 数组 数学

2. 解题

  1. 回溯, 超出时间限制

  2. 最小长度为kshorter, 最大长度为klonger, 中间每个值之间的间隔为longer-shorter

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL