//n个龙珠,在n个城市
//T a b 将包含a的所有龙珠移到b处
//Q a
//龙珠a在哪个城市,这个城市有多少龙珠 , 龙珠a移动了多少次
//并查集记录所有龙珠
//对于移动的次数在find更新的时候优化一下就行
#include
#include
#include
using namespace std ;
const int maxn = 10010 ;
int...
分类:
其他好文 时间:
2015-07-20 23:33:54
阅读次数:
207
题目描述
链接地址
解法
算法解释题目描述Given 2*n + 2 numbers, every numbers occurs twice except two, find them.ExampleGiven [1,2,2,3,4,4,5,3] return 1 and 5ChallengeO(n) time, O(1) extra space.
.链接地址http://www.lintcode...
分类:
其他好文 时间:
2015-07-20 23:32:36
阅读次数:
137
并查集专题 1 struct UF { 2 int rt[MAXN]; 3 void init(void) { 4 memset (rt, -1, sizeof (rt)); 5 } 6 int Find(int x) { 7 re...
分类:
其他好文 时间:
2015-07-20 23:18:09
阅读次数:
120
#includeclass Solution {public: int findMin(vector& nums) { if(nums.size()==0) return INT_MIN; if(nums.size()==1) return nums[0];...
分类:
其他好文 时间:
2015-07-20 23:16:19
阅读次数:
108
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 le...
分类:
其他好文 时间:
2015-07-20 23:00:05
阅读次数:
85
Write a program to find the node at which the intersection of two singly linked lists begins.
For example, the following two linked lists:
A: a1 → a2
↘
...
分类:
其他好文 时间:
2015-07-20 19:43:57
阅读次数:
105
LeetCode上面的题目如下:
Write a program to find the node at which the intersection of two singly linked lists begins.
For example, the following two linked lists:
A: a1 → a2
...
分类:
其他好文 时间:
2015-07-20 19:35:22
阅读次数:
88
Problem Definition:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked ...
分类:
其他好文 时间:
2015-07-20 18:57:03
阅读次数:
95
public ActionResult Delete(int id) { Book book = db.Book.Find(id); if (book == null) { ...
分类:
Web程序 时间:
2015-07-20 18:54:35
阅读次数:
119
Given an array of size n, find the majority element. The majority element is the element that appears more than ? n/2 ? times.You may assume that the array is non-empty and the majority element always...
分类:
其他好文 时间:
2015-07-20 16:32:57
阅读次数:
126