摘要: 1 """ 2 There are a total of n courses you have to take, labeled from 0 to n-1. 3 Some courses may have prerequisites, for example to take course 0 yo 阅读全文
posted @ 2020-02-04 17:00 yawenw 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 You have N gardens, labelled 1 to N. In each garden, you want to plant one of 4 types of flowers. 3 paths[i] = [x, y] describes the existence 阅读全文
posted @ 2020-02-03 21:50 yawenw 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge. 3 If the town judge 阅读全文
posted @ 2020-02-03 21:47 yawenw 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). 3 For example, this binary tree [1,2,2,3,4,4,3] 阅读全文
posted @ 2020-02-02 22:15 yawenw 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). 3 For example: 4 Given b 阅读全文
posted @ 2020-02-02 22:14 yawenw 阅读(92) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 Given a binary tree, find its maximum depth. 3 The maximum depth is the number of nodes along the longest path from the root node down to the 阅读全文
posted @ 2020-02-02 22:12 yawenw 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 For example, given 3 preorder = [3,9,20,15,7] 4 inorder = [9,3,15,20,7] 5 Return the following binary tree: 6 3 7 / \ 8 9 20 9 / \ 10 15 7 11 阅读全文
posted @ 2020-02-02 22:10 yawenw 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 Invert a binary tree. 3 Example: 4 Input: 5 4 6 / \ 7 2 7 8 / \ / \ 9 1 3 6 9 10 Output: 11 4 12 / \ 13 7 2 14 / \ / \ 15 9 6 3 1 16 """ 17 cl 阅读全文
posted @ 2020-02-02 22:06 yawenw 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the othe 阅读全文
posted @ 2020-02-02 22:03 yawenw 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 1 """ 2 We are given a linked list with head as the first node. Let's number the nodes in the list: node_1, node_2, node_3, ... etc. 3 4 Each node may 阅读全文
posted @ 2020-02-01 22:23 yawenw 阅读(202) 评论(0) 推荐(0) 编辑