代码拉取完成,页面将自动刷新
/*
8987 - Subsequence
-------
by jiangshan (@jiangshanmeta) #medium #union
### Question
Given an array of unique elements, return all possible subsequences.
A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements.
For example:
```typescript
type A = Subsequence<[1, 2]> // [] | [1] | [2] | [1, 2]
```
> View on GitHub: https://tsch.js.org/8987
*/
/* _____________ Your Code Here _____________ */
type Subsequence<T extends any[],Prefix extends any[] = []> = T extends [infer F,...infer R]? Subsequence<R,Prefix | [...Prefix,F]>:Prefix
type test = Subsequence<[1,2]>
/* _____________ Test Cases _____________ */
import type { Equal, Expect } from '@type-challenges/utils'
type cases = [
Expect<Equal<Subsequence<[1, 2]>, [] | [1] | [2] | [1, 2]>>,
Expect<Equal<Subsequence<[1, 2, 3]>, [] | [1] | [2] | [1, 2] | [3] | [1, 3] | [2, 3] | [1, 2, 3] >>,
]
/* _____________ Further Steps _____________ */
/*
> Share your solutions: https://tsch.js.org/8987/answer
> View solutions: https://tsch.js.org/8987/solutions
> More Challenges: https://tsch.js.org
*/
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。