type-challenges / type-challenges

Collection of TypeScript type challenges with online judge

Home Page:https://tsch.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

9898 - Appear only once

sunupupup opened this issue · comments

type FindEles<
  T extends any[],
  Arr extends any[] = [],
  Ret extends any[] = []
> = T extends [infer Ele, ...infer Rest]
  ? Ele extends [...Rest, ...Arr][number]
    ? FindEles<Rest, [...Arr, Ele], Ret>
    : FindEles<Rest, [...Arr], [...Ret, Ele]>
  : Ret;