Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8804 - Two Sum #21835

Open
YqxLzx opened this issue Jan 11, 2023 · 0 comments
Open

8804 - Two Sum #21835

YqxLzx opened this issue Jan 11, 2023 · 0 comments
Labels
8804 answer Share answers/solutions to a question en in English

Comments

@YqxLzx
Copy link

YqxLzx commented Jan 11, 2023

// your answers
type createLenByNum<N,T extends any[] = []> = T['length'] extends N ? T : T extends [...infer Rest] ? createLenByNum<N,[...Rest,1]> : []

type TwoSum<T extends any[], U extends number> = T extends [infer F,infer M,...infer Rest] ? 
[...createLenByNum<F>,...createLenByNum<M>]['length'] extends U ? true : 
TwoSum<[F,...Rest],U> extends false ? TwoSum<[M,...Rest],U> : true
 : false
@YqxLzx YqxLzx added answer Share answers/solutions to a question en in English labels Jan 11, 2023
@github-actions github-actions bot added the 8804 label Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8804 answer Share answers/solutions to a question en in English
Projects
None yet
Development

No branches or pull requests

1 participant