Strange behavior of online judge


#1

for the following input
A : [ 1, 2, 3, 4, 5 ]
B : [ 3, 2, 4, 1, 5 ]
When I use my algorithm as custom input it gives correct answer
Returned tree’s PreOrder traversal : [ 1 2 3 4 5 ]
Returned tree’s PostOrder traversal : [ 3 4 2 5 1 ]
But when I Test it for all trivial cases it , it gives different answer on the same input ->
Returned tree’s PreOrder traversal : [ 3 4 5 ]
Returned tree’s PostOrder traversal : [ 5 4 3 ]

How is it possible ?
Please help asap
Thanks In Advance


#2

probably u r not clearing ur global variables before using them … @mahesh-nagarwal


#3

Thanks @beingayushgupta. It worked after resetting the global variable.