We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Data Structures
- Trees
- Tree : Top View
- Discussions
Tree : Top View
Tree : Top View
Sort by
recency
|
961 Discussions
|
Please Login in order to post a comment
public static void topView(Node root) { if (root == null) return;
}
Here's My Python 3 Code
Any suggestion to increase efficiency are appreciated please
I am pretty sure this question has changed over time. 20/20 answers from top leader boards in java don't pass.
Problem's description must be way more clear; a math definition for "top view" may be better.
public static void topView(Node root) { if (root == null) { return;
Queue> queue = new LinkedList<>(); // Map to store the first node at each horizontal distance Map map = new TreeMap<>();