摘要:
Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7return its level order traversal as:[ [3], [9,20], [15,7]]Solution: 1 vector > levelOrder(TreeNo... 阅读全文
摘要:
Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use#as a separator for each node, and,as a separator for node label and each neighbor of the node.As an example, consider the serialized g 阅读全文
摘要:
Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.Summary: Finds the smallest node every round, then links it to the one sorted list. 1 ListNode *mergeKLists(vector &lists) { 2 ListNode * head = NULL; 3 ListNode * pre_node = NULL; 4 ... 阅读全文