diff --git a/solution/0900-0999/0972.Equal Rational Numbers/README.md b/solution/0900-0999/0972.Equal Rational Numbers/README.md index 13ed717827e14..213ac5debbf56 100644 --- a/solution/0900-0999/0972.Equal Rational Numbers/README.md +++ b/solution/0900-0999/0972.Equal Rational Numbers/README.md @@ -12,7 +12,6 @@ -

十进制展开的重复部分通常在一对圆括号内表示。例如:

diff --git a/solution/0900-0999/0972.Equal Rational Numbers/README_EN.md b/solution/0900-0999/0972.Equal Rational Numbers/README_EN.md index 550b3d04c5d85..403da27d509ef 100644 --- a/solution/0900-0999/0972.Equal Rational Numbers/README_EN.md +++ b/solution/0900-0999/0972.Equal Rational Numbers/README_EN.md @@ -10,7 +10,6 @@ -

The repeating portion of a decimal expansion is conventionally denoted within a pair of round brackets. For example:

diff --git a/solution/0900-0999/0982.Triples with Bitwise AND Equal To Zero/README.md b/solution/0900-0999/0982.Triples with Bitwise AND Equal To Zero/README.md index 3ac2dc55945af..5f9446748839a 100644 --- a/solution/0900-0999/0982.Triples with Bitwise AND Equal To Zero/README.md +++ b/solution/0900-0999/0982.Triples with Bitwise AND Equal To Zero/README.md @@ -170,6 +170,29 @@ func max(a, b int) int { } ``` +### **TypeScript** + +```ts +function countTriplets(nums: number[]): number { + const mx = Math.max(...nums); + const cnt: number[] = Array(mx + 1).fill(0); + for (const x of nums) { + for (const y of nums) { + cnt[x & y]++; + } + } + let ans = 0; + for (let xy = 0; xy <= mx; ++xy) { + for (const z of nums) { + if ((xy & z) === 0) { + ans += cnt[xy]; + } + } + } + return ans; +} +``` + ### **...** ``` diff --git a/solution/0900-0999/0982.Triples with Bitwise AND Equal To Zero/README_EN.md b/solution/0900-0999/0982.Triples with Bitwise AND Equal To Zero/README_EN.md index c3f5efa7cdb72..e33eba574f7bb 100644 --- a/solution/0900-0999/0982.Triples with Bitwise AND Equal To Zero/README_EN.md +++ b/solution/0900-0999/0982.Triples with Bitwise AND Equal To Zero/README_EN.md @@ -151,6 +151,29 @@ func max(a, b int) int { } ``` +### **TypeScript** + +```ts +function countTriplets(nums: number[]): number { + const mx = Math.max(...nums); + const cnt: number[] = Array(mx + 1).fill(0); + for (const x of nums) { + for (const y of nums) { + cnt[x & y]++; + } + } + let ans = 0; + for (let xy = 0; xy <= mx; ++xy) { + for (const z of nums) { + if ((xy & z) === 0) { + ans += cnt[xy]; + } + } + } + return ans; +} +``` + ### **...** ``` diff --git a/solution/0900-0999/0982.Triples with Bitwise AND Equal To Zero/Solution.ts b/solution/0900-0999/0982.Triples with Bitwise AND Equal To Zero/Solution.ts new file mode 100644 index 0000000000000..10609f0802152 --- /dev/null +++ b/solution/0900-0999/0982.Triples with Bitwise AND Equal To Zero/Solution.ts @@ -0,0 +1,18 @@ +function countTriplets(nums: number[]): number { + const mx = Math.max(...nums); + const cnt: number[] = Array(mx + 1).fill(0); + for (const x of nums) { + for (const y of nums) { + cnt[x & y]++; + } + } + let ans = 0; + for (let xy = 0; xy <= mx; ++xy) { + for (const z of nums) { + if ((xy & z) === 0) { + ans += cnt[xy]; + } + } + } + return ans; +}