Skip to content

Commit 1d7d29b

Browse files
committed
fiexd config to enhance callstack observing
1 parent 2e21d2f commit 1d7d29b

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

.vscode/launch.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
"request": "launch",
77
"name": "Launch Program",
88
"skipFiles": [ "<node_internals>/**" ],
9-
"program": "${workspaceFolder}/dist/src/main.js",
9+
"program": "${workspaceFolder}/src/main.ts",
1010
"cwd": "${workspaceFolder}",
1111
"console": "integratedTerminal",
1212
"preLaunchTask": "build",
13-
"envFile": "${workspaceFolder}/.env"
13+
"envFile": "${workspaceFolder}/.env",
14+
"sourceMaps": true
1415
}
1516
]
1617
}

src/array/majority-element.ts

+24
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,27 @@ function majorityElement(nums: number[]): number {
1010
}
1111
return candidate!;
1212
}
13+
14+
export function majorityElementDBG() {
15+
const tests = [
16+
{
17+
input: [3, 2, 3],
18+
result: 3
19+
},
20+
{
21+
input: [1, 2, 2, 1, 1, 2, 2],
22+
result: 2
23+
}
24+
];
25+
26+
tests.forEach((test, index) => {
27+
const result = majorityElement(test.input);
28+
if (result === test.result) {
29+
console.log(`${index} success`);
30+
} else {
31+
console.log(`${index} fail`);
32+
console.log(`expected ${test.result}`);
33+
console.log(`got ${result}`);
34+
}
35+
});
36+
}

src/main.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { majorityElementDBG } from "./array/majority-element";
12
import { printTree, TreeNode } from "./bst";
3+
import { lowestCommonAncestorDBG } from "./bst/problems/lowest-common-ancestor";
24
import { HitCounterDBG } from "./scratch_structure/hit-counter";
35

46

5-
HitCounterDBG()
7+
lowestCommonAncestorDBG()

0 commit comments

Comments
 (0)