I have tried to solve
in Python. I don’t but know why, or what is this problem in this code and approach. I tried everything I can to figure the problem. I am getting RE (NZEC) in first case and instead the second case is Accepted.
I start with any random node and use this formula which I made acc. to number of child nodes.
ans = (2A - 1) + (B - 1) (2A) + (C - 1) (2A + 2B - 2) + (D - 1) (2A + 2B + 2C - 4) + (E - 1) (2A + 2B + 2C + 2D - 6) + … and so on depending the number child nodes it has + count is my ans.
where A, B … are the values of the child nodes.
Used recursion to implement to my method. The recursion on any node only happens if there branching further in that node not if it has only 1 child node. If there is branching than updating the count variable (this include combinations among the branches) also.
Can someone please help me out find the problem in this code.