Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the ...
分类:
其他好文 时间:
2015-04-28 22:27:52
阅读次数:
153
problem:
Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s.
For example, given s = "aab",
Retur...
分类:
其他好文 时间:
2015-04-28 18:27:59
阅读次数:
104
UVa 10617 Again Palindrome(经典回文串区间DP)
题意:
给定一个字符串s,对s进行删除操作,使得剩下的子串是回文字符串,问最多有多少种这种子串。
思路:
涉及到回文字符串,首先要想到的肯定是区间DP,如何写出状态转移方程?
直接从题意切入:dp[i, j]表示区间[i, j]最多有多少个这样的子串。
1. s[i] == s[j] 去...
分类:
其他好文 时间:
2015-04-28 18:27:07
阅读次数:
192
题目链接:http://poj.org/problem?id=3974题意:求一给定字符串最长回文子串的长度思路:直接套模板manacher算法code: 1 #include 2 #include 3 #include 4 using namespace std; 5 const int M...
分类:
其他好文 时间:
2015-04-28 15:36:44
阅读次数:
139
一、quicksort 1 int partition(int s[], int l, int r) 2 { 3 int i = l, j = r; 4 int x = s[l]; 5 while (i = x&&i < j) 8 j--; 9 ...
分类:
编程语言 时间:
2015-04-28 09:29:17
阅读次数:
127
题目链接:http://codeforces.com/gym/100548今天晚上突然有了些兴致去学习一下数据结构,然后就各种无意中看到了Palindrome Tree的数据结构,据说是2014年新出的数据结构,也让我回想起了西安打铁时候的经历。这道题的题意其实是比较清晰的,给你两个长度200000...
分类:
其他好文 时间:
2015-04-28 07:03:34
阅读次数:
301
网上有篇关于hive的partition的使用讲解的比较好,转载了:一、背景1、在Hive Select查询中一般会扫描整个表内容,会消耗很多时间做没必要的工作。有时候只需要扫描表中关心的一部分数据,因此建表时引入了partition概念。2、分区表指的是在创建表时指定的partition的分区空间...
分类:
其他好文 时间:
2015-04-27 21:32:50
阅读次数:
464
快排应该是数据结构中排序中最重要的一个,包括其中的patition思想,以及后面的整体的分治思想,都对于解决实际问题有很大的借鉴。快速排序是一种交换排序的方法,不稳定,也就是说如果两个相同的数,快排之后二者可能交换位置。1.首先来看partition函数,函数名partition(data, l, ...
分类:
编程语言 时间:
2015-04-27 19:59:23
阅读次数:
113
题目:LeetCode 009 Palindrome Number题意:判断一个整数是否为回文数,不要用额外空间思路:我不会不用额外空间的方法,需要利用一个长度为20以内的字符串。将整数先写入一个字符串,然后判断首位字符是否相等即可。代码如下: 1 class Solution { 2 public...
分类:
其他好文 时间:
2015-04-27 19:41:45
阅读次数:
130
判断字符串是否是回文。字母、数字都算在内;空串也是回文。【思路】经典回文,两个指针,一个从前向后遍历,一个从后向前,遇到不是要求字符的就跳过。前后指针位置交叉(i>j),则遍历结束。特殊的地方在于,包含字母和数字,如果一一排除,代码很繁琐。【my code】bool isPalindrome(str...
分类:
其他好文 时间:
2015-04-27 09:31:19
阅读次数:
118