Created
January 2, 2017 03:01
-
-
Save liondancer/a484978a1ad110ee05286f20ec29d9ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sortedArrayToBST(nums): | |
if nums: | |
mid = len(nums) / 2 | |
node = TreeNode(nums[mid]) | |
node.left = sortedArrayToBST(nums[:mid]) | |
node.right = sortedArrayToBST(nums[mid + 1:]) | |
return node | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment