From 0b2f9ef1c9283b43aeeefbb7b51b72355b3fa605 Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Tue, 15 Aug 2023 16:10:14 +0800 Subject: [PATCH 1/2] feat: add ts solution to lc/lcof2 problem No.002 --- .../README.md" | 6 ++++++ 1 file changed, 6 insertions(+) diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 002. \344\272\214\350\277\233\345\210\266\345\212\240\346\263\225/README.md" "b/lcof2/\345\211\221\346\214\207 Offer II 002. \344\272\214\350\277\233\345\210\266\345\212\240\346\263\225/README.md" index 5e693bfe8ad1f..cdda8d7103b38 100644 --- "a/lcof2/\345\211\221\346\214\207 Offer II 002. \344\272\214\350\277\233\345\210\266\345\212\240\346\263\225/README.md" +++ "b/lcof2/\345\211\221\346\214\207 Offer II 002. \344\272\214\350\277\233\345\210\266\345\212\240\346\263\225/README.md" @@ -134,6 +134,12 @@ func addBinary(a string, b string) string { ### **TypeScript** +```ts +function addBinary(a: string, b: string): string { + return (BigInt('0b' + a) + BigInt('0b' + b)).toString(2); +} +``` + ```ts function addBinary(a: string, b: string): string { let i = a.length - 1; From 999ae4d3f1ae6326fc91cfd52719c30dd76447ca Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Tue, 15 Aug 2023 16:47:23 +0800 Subject: [PATCH 2/2] feat: update ts solution to lc problem: No.0067 --- solution/0000-0099/0067.Add Binary/README.md | 6 ++++++ solution/0000-0099/0067.Add Binary/README_EN.md | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/solution/0000-0099/0067.Add Binary/README.md b/solution/0000-0099/0067.Add Binary/README.md index f3d8e2116c8b4..04dad5ac14f42 100644 --- a/solution/0000-0099/0067.Add Binary/README.md +++ b/solution/0000-0099/0067.Add Binary/README.md @@ -130,6 +130,12 @@ func addBinary(a string, b string) string { ### **TypeScript** +```ts +function addBinary(a: string, b: string): string { + return (BigInt('0b' + a) + BigInt('0b' + b)).toString(2); +} +``` + ```ts function addBinary(a: string, b: string): string { let i = a.length - 1; diff --git a/solution/0000-0099/0067.Add Binary/README_EN.md b/solution/0000-0099/0067.Add Binary/README_EN.md index f74910ab18035..fb68324beac32 100644 --- a/solution/0000-0099/0067.Add Binary/README_EN.md +++ b/solution/0000-0099/0067.Add Binary/README_EN.md @@ -109,6 +109,12 @@ func addBinary(a string, b string) string { ### **TypeScript** +```ts +function addBinary(a: string, b: string): string { + return (BigInt('0b' + a) + BigInt('0b' + b)).toString(2); +} +``` + ```ts function addBinary(a: string, b: string): string { let i = a.length - 1;