TreeNode* Solution::getSuccessor(TreeNode* A, int B) { return A->right; }


#1

TreeNode* Solution::getSuccessor(TreeNode* A, int B) {
return A->right;
}

3 100 98 102
100

why is this giving a Memory limit Exceeded?


#2

Shit…After 5-6 hours,I realise that this is Invalid Input? Why?

3 100 98 102
100


#3

Akshay Mane Hey,quoting the input format :
First number represents the number of integers in input line. Then follows serialized representation of the tree. The serialization of a binary tree follows a level order description of left and right child of nodes, where -1 signifies a NULL child.
For example,
1
/ \
2 3
/
4

5
will have representation as {1 2 3 -1 -1 4 -1 -1 5 -1 -1}
The first integer on the line indicates the number of integers to follow in the serialized representation of the tree.

In your case the description should be {5 100 98 102 -1 -1 -1 -1}
We are working on making sure we show you the uneditable version of the code which takes input and gives output. Sit tight.