暴力法可解决,速度很慢。 解决办法:哈希表 知识点: map的构造 遍历map使用迭代器,判断条件 插入 pair<int,int> 寻找key是否存在 class Solution { public: vector<int> twoSum(vector<int>& nums, int target ...
分类:
编程语言 时间:
2018-11-10 00:56:52
阅读次数:
167
package com.haiyisoft.cAssistant.utils; import java.io.IOException;import java.util.ArrayList; import java.util.Iterator; import java.util.List; impor ...
分类:
Web程序 时间:
2018-11-09 11:26:48
阅读次数:
364
Given an integer array, return the k-th smallest distance among all the pairs. The distance of a pair (A, B) is defined as the absolute difference bet ...
分类:
其他好文 时间:
2018-11-08 22:09:02
阅读次数:
142
Given a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point o ...
分类:
其他好文 时间:
2018-11-06 22:31:48
阅读次数:
212
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from th... ...
分类:
其他好文 时间:
2018-11-06 11:22:59
阅读次数:
191
小白问小明:“你前面有一个5米深的坑,里面没有水,如果你跳进去后该怎样出来了?”小明:“躺着出来呗,还能怎么出来?”小白:“为什么躺着出来?”小明:“5米深的坑,还没有水,跳下去不死就很幸运了,残是肯定会残的,不躺着出来,那能怎么出来?”小白:“假设没死也没残呢?”小明:“你当我超人了? 那也简单,把脑子里的水放出来就可以漂出来了。”小白:“你脑子里有这么多水吗?”小明:“我脑子里没那么多水我跳下去干嘛?”
分类:
编程语言 时间:
2018-11-06 00:56:40
阅读次数:
489
题目链接:http://poj.org/problem?id=2559 题意: 给出 $n(1 \le n \le 10^5)$ 个宽为 $1$,高为 $h_i(0 \le h_i \le 10^9)$ 的矩形,它们从原点开始并排在 $x$ 轴上, 现在要求出,这个合并产生的图形内部最大的矩形的面积 ...
分类:
其他好文 时间:
2018-11-04 21:23:17
阅读次数:
151
一. 概述 字典又称符号表(symbol table),关联数组(associative array), 映射(map),是一种用于保存键值对(key-value pair)的抽象数据结构。在字典中,一个key和一个value进行关联称为键值对。在字典中每个键都是唯一的,程序可以在字典中根据键查找关 ...
分类:
其他好文 时间:
2018-11-04 19:10:44
阅读次数:
199
题意 "题目链接" Sol 倒着考虑!倒着考虑!倒着考虑! 显然,一个能成为答案的子图一定满足,其中任意节点的度数$ = k$ 那么倒着维护就只用考虑删除操作,如果一个点不合法的话就把它删掉,然后考虑与他相邻的点 如果不合法就继续删 cpp include define Pair pair defi ...
分类:
其他好文 时间:
2018-11-04 15:40:18
阅读次数:
122
为什么要考虑每个时刻呢,考虑每条鱼什么时候被吃不就行了吗,至于时刻相同编号大小的问题,用pair不就可以吗 ...
分类:
其他好文 时间:
2018-11-04 12:46:07
阅读次数:
184