## Not sure how this code works to get the tree diameter

Solution for Not sure how this code works to get the tree diameter is Given Below: I am not sure …

## Which is better DFS or BFS? [closed]

Solution for Which is better DFS or BFS? [closed] is Given Below: Closed. This question is opinion-based. It is not …

## Find all paths in a tree that sum to S

Solution for Find all paths in a tree that sum to S is Given Below: Given a binary tree and …

## is there a better way to exit the recursion?

Solution for is there a better way to exit the recursion? is Given Below: I have this function: class Solution: …

## Convert a tree in 2d array with depth first search

I have a binary tree the following binary tree, which needs to be converted into a 2d array. [[10,5,3,3]] [[10,5,3,-2]] …

## algorithm to enumerate all possible paths

Anyway, I just wondered if there was a way to do this, or maybe this is NP-complete. I don’t believe …

## Sum of the minimum elements in all connected components of an undirected graph

In a city, there is n persons and each person has some friends in the city. (if a is friend …

## Algorithm Problem: Find the longest elementary cycle in a directed graph

The problem is: given a directed graph, find the longest simple cycle in the graph. I’ve searched the question and …

## Find the shortest path to reach a given destination cell in 2D matrix with obstacles

I am working on below interview question and I am confuse on how to use BFS search here. I am …

## to break the tree in even number of nodes

You are given a tree (a simple connected graph with no cycles). Find the maximum number of edges you can …