Geek wants to know the traversals required to construct a unique binary tree. Given a pair of traversal, return true if it is possible to construct unique binary tree from the given traversals otherwise return false.
Each traversal is represented with an integer: preorder - 1, inorder - 2, postorder - 3.   
Example 1:
Input:
a = 1, b=2
Output: 1
Explanation: We can construct binary tree using inorder traversal and preorder traversal. 
Example 2:
Input: a = 1, b=3
Output: 0 
Explanation: We cannot construct binary tree using preorder traversal and postorder traversal. 
Constraints:
1 <= a,b <=3
Your Task:
You don't need to read input or print anything. Your task is to complete the function isPossible() which takes a and b as input parameters and returns true or false.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)

Source: geeksforgeeks | Difficulty: EASY
Tags: Graph traversal

Starter code: #User function Template for python3



class Solution:

    def isPossible(self, a, b):

        #Code here

Solutions:
class Solution:

	def isPossible(self, a, b):
		return 1 if (a == 2 or b == 2) and (not (a == 2 and b == 2)) else 0


class Solution:

	def isPossible(self, a, b):
		if a == b:
			return False
		if a == 2 or b == 2:
			return True
		return False


class Solution:

	def isPossible(self, a, b):
		if a == 2:
			return b == 1 or b == 3
		elif b == 2:
			return True
		return False


class Solution:

	def isPossible(self, a, b):
		if (a == 1 or a == 3) and b == 2:
			return 1
		elif a == 2 and (b == 1 or b == 3):
			return 1
		return 0


class Solution:

	def isPossible(self, a, b):
		traversal = [a, b]
		if 2 in traversal and (1 in traversal or 3 in traversal):
			return True
		return False


class Solution:

	def isPossible(self, a, b):
		return True if (a + b) % 2 != 0 else False


class Solution:

	def isPossible(self, a, b):
		if a == 1 and b == 3:
			return False
		elif a == 3 and b == 1:
			return False
		elif a == b:
			return False
		else:
			return True


class Solution:

	def isPossible(self, a, b):
		if a == 1 and b == 3 or (a == 3 and b == 1) or a == b:
			return False
		return True


class Solution:

	def isPossible(self, a, b):
		if a != 2 and b != 2:
			return False
		elif a == b:
			return False
		return True


class Solution:

	def isPossible(self, a, b):
		if a != b:
			l = [a, b]
			if 2 in l:
				return True
		return False