Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

Minimum Absolute Difference in BST

S

For solution 1 using in-order traversal, Space complexity is O(h) where h = height of tree ?

J

@spoiledpiggy_js For binary tree traversal, time complexity is O(n), since in this example you're hitting each node

A

@Allent51 C++ allows it. The return value will be just ignored, or destroyed if it is an object with no reference.

@StefanPochmann You are right, Stefan. I think I should use Long.MAX_VALUE here.

V

convert tree to list and calculate the minimum difference .that 's a good one and straight forward .

P

@alexander That is because you are doing a boolean "OR" rather than a logical OR, which short circuits.

Space complexity is O(n). Can reduce to O(log(n)).

L

Recursion is never O(1) space

No one has replied

X

@tamhankar Not O(1) space

@shawngao Yes, you're right

F

I do think Java suits you better, not python...

Disabled Categories are greyed out

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.