hackerrank: All Domains ↠ Algorithms ↠ Graph Theory ↠ Even Tree

Problem Statement: link

This is a super cool problem, you are given a tree and you have to find the maximum number of cuts to a tree such that after the cuts the individual trees have even number of nodes or odd number of edges. it is very easy to formulate a recurrence, if the number of children are even then increment the break count.

My Solution:

https://gist.github.com/8ae83807578c8753f139

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s