#C8946. Odd Even Level Difference in Binary Tree

    ID: 52984 Type: Default 1000ms 256MiB

Odd Even Level Difference in Binary Tree

Odd Even Level Difference in Binary Tree

You are given a binary tree represented in level order. Each node of the tree contains an integer value. A missing node is represented by the token null. The root of the tree is at level 1, which is considered an odd level.

Your task is to compute the difference between the sum of the nodes at odd levels and the sum of the nodes at even levels. In other words, if \(S_{odd}\) is the sum of nodes at odd-numbered levels and \(S_{even}\) is the sum of nodes at even-numbered levels, you should calculate and output:

\(\text{Answer} = S_{odd} - S_{even}\)

If the tree is empty, output 0.

inputFormat

The input is read from standard input (stdin) and consists of a single line containing space-separated tokens representing the level order traversal of the binary tree. Use the token null (without quotes) to denote an absent (null) node.

For example: 1 2 3 null null 4 5

outputFormat

Output to standard output (stdout) a single integer which is the computed difference between the sum of nodes at odd levels and even levels.

## sample
1
1

</p>