5051. 有效的回旋镖
构建两个向量,判断向量是否平行即可。
class Solution {
public boolean isBoomerang(int[][] points) {
int a = points[0][0]-points[1][0];
int b = points[0][1]-points[1][1];
int c = points[2][0]-points[1][0];
int d = points[2][1]-points[1][1];
return a*d != b*c;
}
}
5050. 从二叉搜索树到更大和树
一开始看中文题意没看懂,这翻译也太直了。其实题意就是求二叉搜索树中序遍历的序列的后缀和,然后将后缀和的值替换节点的值。直接中序遍历即可。
Given the root of a binary search tree with distinct values, modify it so that every
node
has a