Find Minimum in Rotated Sorted Array II Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-...
分类:
其他好文 时间:
2014-10-24 20:42:30
阅读次数:
299
Find Minimum in Rotated Sorted ArrayQuestion SolutionSuppose a sorted array is rotated at some pivot unknown to youbeforehand.(i.e., 0 1 2 4 5 6 7 mig...
分类:
其他好文 时间:
2014-10-24 20:26:46
阅读次数:
258
昂神的解题报告:http://sd-invol.github.io/2014/10/22/Anshan-2014-G/
我来对他的话进行翻译就好了…
之所以看出最小割 是因为每个位置有两种方案 这样形成二分图后 我们要进行决策 最小割也就变成了进行决策所要丢掉的最小价值
之所以根据每个位置的二进制表示中1的个数来决定该位置两种决策放在左边还是右边 是为了避免二分图中同一个集...
分类:
其他好文 时间:
2014-10-24 18:59:31
阅读次数:
269
Sort ColorsGiven an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the ...
分类:
其他好文 时间:
2014-10-24 18:38:49
阅读次数:
258
题目大意:给定一张图,和每个点的油价,知道每条路的耗油量,给定一些询问,求从起点到终点用指定油箱容量的车所得到的最小耗费。
解题思路:BFS+优先队列
优先队列介绍:采用stl中的priority_queue实现。priority_queue默认的是最大优先队列,声明时只要priority_queue q就行了。如果是最小堆,麻烦一些
priority_queue,cmp> q。其中cmp函...
分类:
其他好文 时间:
2014-10-24 14:45:31
阅读次数:
205
Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity ...
分类:
其他好文 时间:
2014-10-24 14:16:18
阅读次数:
238
Spiral Matrix IIGiven an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should retu...
分类:
其他好文 时间:
2014-10-24 12:35:31
阅读次数:
259
今天看到CSDN博客的勋章换了图表,同时也增加显示了博客等级,看起来都听清新的,感觉不错!
【题目】
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.
click to show follow up.
Follow up:
Did yo...
分类:
其他好文 时间:
2014-10-24 11:01:34
阅读次数:
219
题目来源:hihoCoder 1037 数字三角形解题思路:请好好看看 提示一、提示二、提示三具体算法(java版,可以直接AC)import java.util.Scanner;public class Main { public static int[][] rewards; pub...
分类:
其他好文 时间:
2014-10-23 23:55:08
阅读次数:
222
首先存这些字符,用trie来存,通过trie就很容易联想到树型DP,这里的DP就不是取最优值之类的了,而是用来弄到达某个节点的胜负情况。
我们首先设节点v,win[v]代表已经组装好的字符刚好匹配到v了,然后需要进行下一步匹配时,先手是否可以赢,lose[v]则代表先手是否会输。
叶节点,win[v] = false, lose[v] = true.
其他节点 win[v] = win[v] | !win[child], lose[v] = lose[v] | !lose[child]. (因为每次赢的...
分类:
其他好文 时间:
2014-10-23 22:42:57
阅读次数:
191