Skip to content
Advertisement

Count nodes that are bigger than all their sons

I have to make a programm that counts the nodes bigger than their sons without including the leaf nodes for example:

JavaScript

This is my approach:

JavaScript

But I can’t see the error

Advertisement

Answer

Assuming info is an int, this could work for you. I haven’t tested the code, so let me know if there are issues.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement