We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bcafd91 commit 63092efCopy full SHA for 63092ef
README.md
@@ -45,6 +45,8 @@ Step 2. Add the dependency
45
46
<summary>展开查看</summary>
47
48
+https://leetcode.cn/problems/cycle-length-queries-in-a-tree
49
+
50
https://leetcode.cn/problems/two-sum-iii-data-structure-design/
51
52
https://leetcode.cn/problems/minimum-adjacent-swaps-for-k-consecutive-ones
cycle-length-queries-in-a-tree/index.ts
@@ -0,0 +1,15 @@
1
+function cycleLengthQueries(_n: number, queries: number[][]): number[] {
2
+ return queries.map(([a, b]) => {
3
+ let ans = 1;
4
+ while (a !== b) {
5
+ if (a > b) {
6
+ a = a >> 1;
7
+ } else {
8
+ b = b >> 1;
9
+ }
10
+ ans++;
11
12
+ return ans;
13
+ });
14
+}
15
+export default cycleLengthQueries;
0 commit comments