Type Challenges Judge

Subsequence

提出詳細

type SubsequenceFromHead<T> = T extends [infer Head] ? [] | [Head] : T extends [infer Head, ...infer Tail] ? [] | [Head, ...SubsequenceFromHead<Tail>] : never type Subsequence<T> = T extends [unknown, ...infer Tail] ? SubsequenceFromHead<T> | Subsequence<Tail> : never
提出日時2022-06-24 02:43:35
問題Subsequence
ユーザーcisdur
ステータスWrong Answer
テストケース
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] >>, ]