[LeetCode]#94. Binary Tree Inorder Traversal

Input: root = [1,null,2,3]
Output: [1,3,2]
  1. Please see leetcode solution, it is very clear.
from binarytree import Node
root = Node(1)
root.right = Node(2)
# Getting binary tree
print('Binary tree :', root)
#root = [1,null,2,3]
class Solution:
def inorderTraversal(self, root):
if root:
return self.inorderTraversal(root.left) + [root.val] + self.inorderTraversal(root.right)
return []




Interesting in any computer science.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Hey friends…

Quiz | Computer Fundamentals | Set 24

Cassandra Data modelling

TDD Conference 2021 — On The Relationship Between Units Of Isolation And Test Coupling — Mario…

Blue Planet II, the BBC, and the Semantic Web: a tale of lessons forgotten and opportunities lost

Solving 100 Data structure and Algorithms(DSA) questions within 16 hours

WAX Guild Candidate: WAX sw/eden

How object and class attributes work

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Fatboy Slim

Fatboy Slim

Interesting in any computer science.

More from Medium

LeetCode Patterns Adventure 15 — Reverse Linked List

Use of python dictionary get function

Longest Valid Parentheses — Leetcode Python

Introduction to LinkedList