A - Removing Columns
贪心。
只能是竖着不递减的就尽量选上,当某一行出现字典序大于上一行的情况的时候,就不用再考虑这一行。
代码如下:
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
char s[1002][1002...
分类:
其他好文 时间:
2014-12-27 11:25:03
阅读次数:
143
Remove Duplicates from Sorted List IIGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the or...
分类:
其他好文 时间:
2014-12-27 11:22:42
阅读次数:
176
Remove Duplicates from Sorted List IIGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the or...
分类:
其他好文 时间:
2014-12-27 11:16:12
阅读次数:
161
题目地址:https://oj.leetcode.com/problems/excel-sheet-column-title/题目内容:Given a positive integer, return its corresponding column title as appear in an Ex...
分类:
其他好文 时间:
2014-12-27 06:44:00
阅读次数:
152
题目链接:http://codeforces.com/problemset/problem/499/A题目意思:有两种按钮:1、如果当前观看的时间是 t,player 可以自动处理下一分钟,姑且理解为跳到t+1; 2、直接跳过 x 分钟,如果player在第 t 分钟,则可以跳到 t+x。问恰好可以...
分类:
其他好文 时间:
2014-12-27 00:12:21
阅读次数:
243
题目链接:http://codeforces.com/problemset/problem/499/B题目意思:给出两种语言下 m 个单词表(word1, word2)的一一对应,以及 professor's lecture 的 n 个单词。问记下来的笔记是什么。对于professor's lect...
分类:
其他好文 时间:
2014-12-27 00:10:21
阅读次数:
262
Flatten Binary Tree to Linked ListGiven a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / ...
分类:
其他好文 时间:
2014-12-26 14:19:14
阅读次数:
310
解题报告http://blog.csdn.net/juncoder/article/details/38160591题目传送门(POJ)题目传送门(HDU)题意:求满足条件的最大集合:集合内不论什么两个人都没有浪漫关系思路:跟POJ2771一样的题,变的简单多了。POJ2771解题报告#includ...
分类:
其他好文 时间:
2014-12-26 12:55:37
阅读次数:
133
【题目】
Merge k sorted
linked lists and return it as one sorted list. Analyze and describe its complexity.
合并几个有序链表为一个,分析算法复杂度。
【分治】
直观的想法是两两合并,有两种方法:1)list1和list2合并为newlist2,newlist2再和list3合...
分类:
其他好文 时间:
2014-12-26 11:12:18
阅读次数:
129
/*这题后面那个visit的判断有点浪费时间。没有优化好。。后来看了飞神的解题报告,在DFS算法中进行优化for(i=0; i<n; i++)
{
if(!color[i]&&map[x][i])
{
color[i]=-color[x];
if(dfs(i,n))
...
分类:
其他好文 时间:
2014-12-25 23:43:42
阅读次数:
435