Skip to main content
deleted 20 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

I am posting an improved version of the algorithm put forward in the questionquestion for anyone that might be looking for a more concise answer.

I added a constructor to the BoundsBounds class which allows me to assign the Bounds instanceBounds instance directly into the stack  :

I have added the Node class that I am using at @greybeard's suggestion. It only has three fields; fields: left child node, right child node and an integer val.

The runtime is O(n)\$O(n)\$. The primary advantage it has over @coderodde's solution is that it does not require the existence of the parent node.

I am posting an improved version of the algorithm put forward in the question for anyone that might be looking for a more concise answer.

I added a constructor to the Bounds class which allows me to assign the Bounds instance directly into the stack  :

I have added the Node class that I am using at @greybeard's suggestion. It only has three fields; left child node, right child node and an integer val.

The runtime is O(n). The primary advantage it has over @coderodde's solution is that it does not require the existence of the parent node.

I am posting an improved version of the algorithm put forward in the question for anyone that might be looking for a more concise answer.

I added a constructor to the Bounds class which allows me to assign the Bounds instance directly into the stack:

I have added the Node class that I am using at @greybeard's suggestion. It only has three fields: left child node, right child node and an integer val.

The runtime is \$O(n)\$. The primary advantage it has over @coderodde's solution is that it does not require the existence of the parent node.

Post Made Community Wiki by Jamal
Notice removed Insufficient justification by Jamal
added 148 characters in body
Source Link
Haider
  • 267
  • 2
  • 9

The runtime is O(n). The primary advantage it has over @coderodde's solution is that it does not require the existence of the parent node.

The runtime is O(n). The primary advantage it has over @coderodde's solution is that it does not require the existence of the parent node.

deleted 1 character in body
Source Link
Haider
  • 267
  • 2
  • 9

I have added the Node class that I am using at @greybeard's suggestion. It only has three fields; left child node, right child node and thean integer val.

I have added the Node class that I am using at @greybeard's suggestion. It only has three fields; left child node, right child node and the integer val.

I have added the Node class that I am using at @greybeard's suggestion. It only has three fields; left child node, right child node and an integer val.

added 160 characters in body
Source Link
Haider
  • 267
  • 2
  • 9
Loading
added 101 characters in body
Source Link
Haider
  • 267
  • 2
  • 9
Loading
deleted 1 character in body
Source Link
Haider
  • 267
  • 2
  • 9
Loading
deleted 1 character in body
Source Link
Haider
  • 267
  • 2
  • 9
Loading
Notice added Insufficient justification by Jamal
deleted 1 character in body
Source Link
Haider
  • 267
  • 2
  • 9
Loading
Source Link
Haider
  • 267
  • 2
  • 9
Loading