- 博客(12)
- 收藏
- 关注
原创 Textbook Ex.8.22
a) 显然 FAS 是可在多项式时间内验证的,因此属于NP。b) 设G 的一个大小为b 的顶点覆盖为C ,对于任意顶点vi ∈C ,设其在G'中相对应的顶点为wi 和wi' ,则将边(wi ,wi') 添加到E '。对C中的每个顶点都这样处理后,所得到的边集E '即是G'的一个大小为b 的最小反馈弧集。因为对于顶点wi 和wi',当去掉边( wi, wi ')
2017-07-12 00:52:30 297
原创 Leetcode 257 Binary Tree Paths
Q:Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]
2017-07-12 00:42:45 242
原创 Leetcode 199 Binary Tree Right Side View
Q:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree,
2017-07-06 11:58:09 212
原创 Leetcode 100 Same Tree
Q:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
2017-07-06 00:23:48 246
原创 Leetcode 94 Binary Tree Inorder Traversal
Q:Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].A:/*
2017-07-05 20:50:29 422
原创 Leetcode 207 Course Schedule
Q:There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is express
2017-06-26 00:20:46 226
原创 Leetcode 104 Maximum Depth of Binary Tree
Q:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.A:/** * Definition for
2017-06-25 23:44:25 194
原创 leetcode 513 Find Bottom Left Tree Value
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * };
2017-06-23 15:24:14 316
原创 Leetcode 332 Reconstruct Itinerary
class Solution {public: vector findItinerary(vector> ticket) { vector itinerary; if(ticket.size()==0){ return itinerary;} map> map;
2017-06-21 21:50:36 428
原创 Leetcode 169 Majority Element
class Solution {public: int majorityElement(vector& nums) { int majEle; int count = 0; for(int i = 0; i if(count == 0) { majEle = nums[i]; count++;
2017-04-04 12:44:33 428
原创 Leetcode 53 Maximum Subarray
class Solution {public: int maxSubArray(vector& nums) { int maxSub1 = nums[0] + nums[1]; int maxSub2 = nums[0]; int both; int s1, s2; int add; for(int i = 0;
2017-03-13 20:36:27 217
原创 Leetcode 495 Teemo Attacking
In LLP world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascending time series towards Ashe and the poisoning tim
2017-02-26 19:06:14 373
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人