ERROR: Traceback (most recent call last):
File “script.py”, line 44, in
k = int(input())
EOFError: EOF when reading a line
MY CODE:
ERROR: Traceback (most recent call last):
File “script.py”, line 44, in
k = int(input())
EOFError: EOF when reading a line
MY CODE:
sry mycode: class TreeNode: def init(self,data,left=None,right=None): self.data = data self.left = left self.right = right def setLeft(self,val): self.left = TreeNode(val) def setRight(self,val): self.right = TreeNode(val) def insert(root,val): if root.data == None: root.data = val queue = [root] n = 1 while(n>=0): k = queue.pop() n-=1 if root.left: queue.append(root.left) n+=1 else: root.left = TreeNode(val) break if root.right: queue.append(root.right) n+=1 else: root.right = TreeNode(val) break return root def createTreeFromArray(arr): root = TreeNode(arr[0]) for i in range(1,len(arr)): insert(root,arr[i]) return root if name==“main”: k = int(input()) for i in range(k): myarr = list(map(int,input().split())) x = int(input()) root = createTreeFromArray(myarr) count = 0 def subTreesWithGivenSum(root,x): if root: leftval = 0 rightval = 0 if root.left: leftval = root.left.data if root.right: rightval = root.right.data if root.data+rightval+leftval == x: count+=1 subTreesWithGivenSum(root.left,x) subTreesWithGivenSum(root.right,x) else: return print(count)