Total subtrees with given sum

Problem : https://hack.codingblocks.com/app/contests/1499/1600/problem
My solution : https://ide.codingblocks.com/s/228114

Why I am getting wrong output ?

Please check my updated code. Its still giving wrong answer. https://ide.codingblocks.com/s/228136

hello @vaishnavtannu
some information is missing in the question ,it is not mentioned how binary tree is constructed.

The values in the string are in the order of level order traversal of the tree. Can you please tell what I am doing wrong?

check input format then,
in input format it is mention that first input is number of test cases u are treating as n.

https://ide.codingblocks.com/s/228136 Please check this. Here I am considering no. of test cases

You are not handling multiple digit values example consider test case:->
1
1 2 3 4444 5555
5

you are also not handling -ve values :->
1
-1 1 -2 -2
3

i have modifed your code its getting accepted now:
take a look at your create Tree function ->