算法题
- 链接:https://leetcode-cn.com/problems/number-of-boomerangs/
- 解答
```javascript
var numberOfBoomerangs = function(points) {
let ans = 0;
for (const p of points) {
const cnt = new Map();
for (const q of points) {
const dis = (p[0] - q[0]) * (p[0] - q[0]) + (p[1] - q[1]) * (p[1] - q[1]);
cnt.set(dis, (cnt.get(dis) || 0) + 1);
}
for (const [_, m] of cnt.entries()) {
ans += m * (m - 1);
}
}
return ans;
};
<a name="FXU0i"></a>
### 手写题:
- 链接:[https://bigfrontend.dev/zh/typescript/Trim](https://bigfrontend.dev/zh/typescript/Trim)
- 答案
```javascript
type Trim<T extends string> =
T extends ` ${infer Left}` ? Trim<Left> :
(T extends `${infer Right} ` ? Trim<Right> :
T);